I am using below code for automatically redirect to the page in a fraction of seconds.
<script language="Javascript" type="text/javascript">
<!--
var testTimerID;
testTimerID = window.setTimeout(autoDirect, 30*250 );
function autoDirect() {
window.location = 'home';
}
</script>
- This script works fine in all browser except in safari browser.it does not automatically redirect to the another page(home). what is the issue?.how can i solve开发者_C百科 it?.
Try it like this:
<script language="Javascript" type="text/javascript">
//<!--
var testTimerID;
testTimerID = window.setTimeout(function(){
window.location.href = '/home';
}, 30*250 );
//-->
</script>
Usually JS does not work properly and in same way through all the web browsers... Therefore I advise to use jQuery as it is debugged for all common browsers...
Try aslo reading through this: How to redirect to another webpage in JavaScript/jQuery?
Also instead of relative URL You shoudl use absolute like http://www.mydomain.com/home/
, so the code should be:
...
window.location.href = 'http://www.mydomain.com/home/';
...
.
This works perfectly in Safari 5 for windows
<script language="Javascript" type="text/javascript">
var testTimerID;
testTimerID = window.setTimeout(autoDirect, 30*250 );
function autoDirect() {
window.location = 'http://google.com/';
}
</script>
精彩评论