Anchor search attribute
Definition and usage
search
Attribute setting or return href attribute value of the query string part.
The query string is the part after the question mark (?) in the URL. It is usually used for parameter passing.
See also:
JavaScript Reference Manual:location.search attribute
Example
Example 1
Return the query string part of the link:
var x = document.getElementById("myAnchor").search;
Example 2
Change the query string part of the link:
document.getElementById("myAnchor").search = "somenewsearchvalue";
Syntax
Return search attribute:
anchorObject.search
Set search attribute:
anchorObject.search = querystring
属性值
值 | 描述 |
---|---|
querystring | 规定 URL 的搜索部分。 |
技术细节
返回值: | 字符串值,表示 URL 的查询字符串部分,包括问号 (?)。 |
---|
浏览器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |