开发者

Automatic Page redirection not working in safari browser

开发者 https://www.devze.com 2023-03-02 17:38 出处:网络
I am using below code for automatically redirect to the page in a fraction of seconds. <script language=\"Javascript\" type=\"text/javascript\">

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消