Get the current URL of the document in the window in JavaScript

Description

The following code shows how to get the current URL of the document in the window.

Example


<html>
<script language="JavaScript">
<!--  w ww . j av a2s.c o  m-->
document.writeln(window.location);
</script>
</html>

Click to view the demo

The code above generates the following result.

Get the current URL of the document in the window in JavaScript