简体   繁体   English

元标记中的javascript在Firefox和Internet Explorer上不起作用

[英]javascript in meta tag not working on firefox and internet explorer

I noticed this: 我注意到了这一点:

<meta HTTP-EQUIV="REFRESH" CONTENT="0;URL=javascript:alert(2)">

Only works on chrome, so my question is, how can I execute JavaScript within a meta tag that will work on chrome, firefox and internet explorer? 仅适用于chrome,所以我的问题是,如何在适用于chrome,firefox和Internet Explorer的meta标签内执行JavaScript? As far as my tests have gone, that only works in chrome and not on internet explorer and firefox. 就我的测试而言,它仅适用于chrome,不适用于Internet Explorer和Firefox。

javascript: URIs where disabled in Firefox via MSFA 2009-22 / CVE-2009-1312 . javascript:在Firefox中通过MSFA 2009-22 / CVE-2009-1312禁用的URI。 I guess Internet Explorer disables such URIs for the same reason. 我猜出于相同的原因,Internet Explorer禁用了此类URI。

Hence you cannot use javascript: URIs for meta-refresh. 因此,您不能使用javascript: URI进行元刷新。 Of course you're still free to do something like: 当然,您仍然可以自由地执行以下操作:

<script>
  setTimeout(function() { alert(2); }, 0);
  // or just
  alert(2);
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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