How to obtain the URL of the current page

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 role of two properties are exactly the same as all the current web page URL returns a string of;

2. Document.documentURI inherited from the Document interface for all documents;

3. document.URL inherited from HTMLDocument interface is only available in HTML documents;

 

Guess you like

Origin www.cnblogs.com/aisowe/p/11536035.html