Controlling page navigation using javascript

In this example, we control the navigation dynamically using javascript

<html>
<head>
<title></title>
<script language="javascript" type="text/javascript">

function navigate()
{
window.location.href="page1.html";
}

</script>

</head>
<body >
<input id="btn" name="btn" type="button" value="click here" onclick="window.open('meta.html');" />

<input id="btn1" name="btn1" type="button" value="Go to Page1" onclick="window.location.href='page1.html';" />
<br />
<a href="page1.html">Page1.html</a>
<br />
<a href="javascript:;" onclick="window.location.href='page1.html';">Page1.html</a>
<br />
<a href="javascript:;" onclick="navigate();">Page1.html</a>


</body>
</html>

The above example also shows how we can display a popup window using javascript. To display the popup, the simplest method call is window.open("pagename");

Add a Comment

Your email address will not be published. Required fields are marked *