CancelImage Upload

How to load a page's current URL with JavaScript

To load the a browser's current location via JavaScript the following code is required. Simply specify the document object, and request the extension URL:

var location = document.URL;

For a more extensive example of how to output the current URL to a HTML document via getElementById() try the following example:

<html>
<head>
<title>How to load a page's current URL with JavaScript</title>
<script type="text/javascript">
function loadLocation()
{

        var location = document.getElementById("location");

        location.innerHTML = document.URL;

}
</script>

</head>
<body onload="javascript:loadLocation();">

Current URL: <i id="location"></i>
</body>
</html>


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com