Home >Web Front-end >JS Tutorial >How to get the url of the website in js
How to get the url of the website with js
1. document.documentURI
document.documentURI; // "https://i.cnblogs.com/EditPosts.aspx?opt=1"
2. document.URL
document.URL; // "https://i.cnblogs.com/EditPosts.aspx?opt=1"
Note:
1. The functions of the two attributes are exactly the same. Both return a string of the current web page URL;
2. document.documentURI inherits from the Document interface and is applicable to all documents;
3. document.URL inherits from the HTMLDocument interface and is only applicable to HTML documents;
Recommended tutorial: " JS tutorial》
The above is the detailed content of How to get the url of the website in js. For more information, please follow other related articles on the PHP Chinese website!