Home > Web Front-end > JS Tutorial > body text

How to get the url of the website in js

hzc
Release: 2020-06-17 17:10:50
Original
4488 people have browsed it

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"
Copy after login

2. document.URL

document.URL;
// "https://i.cnblogs.com/EditPosts.aspx?opt=1"
Copy after login

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!

Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!