开发者

How Can I mimic a meta refresh with JS?

开发者 https://www.devze.com 2022-12-24 14:51 出处:网络
I tried to do <script type=\"text/java开发者_开发百科script\"> //<![CDATA[ document.write(\'<meta http-equiv=\"refresh\" content=\"0;url=index.php\" />\');

I tried to do

<script type="text/java开发者_开发百科script"> //<![CDATA[ document.write('<meta http-equiv="refresh" content="0;url=index.php" />'); //]]> </script>

but that doesn't validate on strict =[

how can I do that with JS alone?


How about:

location.href = 'index.php';

To refresh the same page:

location.reload();

To wait 2 seconds before reloading (as <meta> can do):

setTimeout(function(){ location.reload(); }, 2000);
0

精彩评论

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