In Javascript, how to redirect another page from the current page?

 Posted by Vivek.Ramapuram on 8/5/2014 | Category: JavaScript Interview questions | Views: 493 | Points: 40
Answer:

Here in javascript, we should use location.href that should be done by alert method. If we want to get the current url of the web page from this we can set location.href if we want to redirect current page in to another page.

Example:
<script type="text/javascript">

function TestFunction(){
alert(location.href);
location.href="http://www.google.com";
}
</script>
<input type="Button" id="btntest" onclick="TestFunction()" value="clickme"


Asked In: While Learning | Alert Moderator 

Comments or Responses

Login to post response