Location searchProperty

Location 对象参考手册Location Object

Definition and Usage

The search property is a readable and writable string that sets or returns the query portion of the current URL (the part after the question mark ?).

Syntax

location.search


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the search property


Example

Example

Return the query portion of the URL. Assuming the current URL is http://www.example.com/submit.htm?email=someone@ example.com:

<script>

document.write(location.search);

</script>

The above example output:

?email=someone@example.com


Location 对象参考手册Location Object Other Extensions