我如何让这个脚本在ios chrome上运行

时间:2017-07-31 13:27:39

标签: javascript ios google-chrome

好的,所以下面的代码适用于除ios chrome和IE之外的所有浏览器。 可以进行哪些更改以使其与这些浏览器兼容

<script type="text/javascript">
  !function(){
    var campaign_link = "http://example.com/time&"; // REPLACE WITH YOUR LINK
    var t;             
    try{
      for(t=0;10>t;++t)history.pushState({},"","#");
      onpopstate=function(t){t.state&&location.replace(campaign_link)}}
    catch(o){}
  }();
</script>

1 个答案:

答案 0 :(得分:0)

由于历史记录API,您收到错误。它不支持浏览器

Internet Explorer 9下面的所有版本肯定不支持history.pushState()history.popState()

iOS在HTML5历史记录API中存在一些错误。

您可以尝试:

window.addEventListener("popstate", function(e) {
    window.location.href = location.href;
});
相关问题