Home >Web Front-end >JS Tutorial >JavaScript implements a simple method to obtain the current web page URL_javascript skills

JavaScript implements a simple method to obtain the current web page URL_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:33:221645browse

The example in this article describes how to simply obtain the current web page URL using JavaScript. Share it with everyone for your reference, the details are as follows:

Here is a demonstration of using JavaScript to obtain the URL of the current web page. It is a useful function. Click "Run" to see the effect.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-show-nav-url-codes/

The specific code is as follows:

<html>
<head>
<title>取得目前页面页的网址</title>
</head>
<body>
目前页面网址为:
<script language="javascript">
<!--
 url = window.location.href;
 document.write(url);
-->
</script>
</body>
</html>

I hope this article will be helpful to everyone in JavaScript programming.

Statement:
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