简体   繁体   中英

Javascript + meta refresh keeps reloading

I have below code.But this keeps on reloading the page instead of redirecting.

    <script>
function my()
        {
          document.write("<meta content='0;url=http://google.com' http-equiv='refresh'></meta>");
        }
      </script>
      <center> <input name='image' onclick='my();' src='http://i.imgur.com/jgI5Ryt.png' type='image'/></center>

Note : i need meta refresh for some reason.So please help me with above code only.

You can achieve it by replacing

document.write("<meta content='0;url=http://google.com' http-equiv='refresh'></meta>");

with

$('head').append('<meta content='0;url=http://google.com' http-equiv='refresh'></meta>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM