开发者

Is it possible to get the string displayed in the URL bar using javascript?

I realize that window.location.href sometimes returns something other than the string displayed in the URL bar. Is there any 开发者_如何学Goway to get the string displayed in the URL bar in Javascript?

When I visit www.google.com using this user script, document.location.href is not always "www.google.com" as expected.


location has many properties which should allow you to get the part you want. Have a look at its documentation [MDN].

Chrome, by default, hides the protocol of the URI (see also @Andy E's comment).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜