X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor search Property

Anchor Object Reference Anchor Object

Example

Return the querystring part of a link:

var x = document.getElementById("myAnchor").search;

The result of x will be:

?id=searchtest

Try it yourself »


Definition and Usage

The search property sets or returns the querystring part of the href attribute value.

The querystring is the part of the URL after the question mark (?). This is often used for parameter passing.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The search property is supported in all major browsers.


Syntax

Return the search property:

anchorObject.search

Set the search property:

anchorObject.search=querystring

Property Values

Value Description
querystring Specifies the search part of a URL

Technical Details

Return Value: A String, representing the querystring part of the URL, including the question mark (?)


More Examples

Example

Change the querystring part of a link:

document.getElementById("myAnchor").search = "somenewsearchvalue";

Try it yourself »

Related Pages

JavaScript reference: location.search Property


Anchor Object Reference Anchor Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook