If you want to redirect to another page,simply use window.location property of javascript. You can use window.loacation.replace or window.loaction.href to accomplish this purpose.
If you use window.location.replace,the replace() method do not save the originating page in the history of session so the user wont be able to use the back button of browser to navigate to it.
Here is an example of how to use it:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script type="text/javascript">
function Redirect() {
window.location.replace("http://www.findnerd.com/");
}
setTimeout("Redirect()", 10000);
</script>
</head>
<body>
<p>Hello everyone!</p>
</body>
</html>
similar to window.location.replace:
window.location.href="http://www.findnerd.com";
similarly you can use jQuery to do this:
var url = "http://www.findnerd.com";
$(location).attr('href',url);
I would prefer using jQuery because it offers cross browser compatibility.
0 Comment(s)