且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用JavaScript获取当前网址?

更新时间:2023-10-25 18:11:22

使用:

window.location.href 

如评论中所述,下面的行可以使用,但它会被Firefox窃听。

As noted in the comments, the line below works, but it is bugged for Firefox.

document.URL;

参见 DOMString类型的URL,只读

See URL of type DOMString, readonly.