Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Fire document.ready on back按钮IE11_Javascript_Jquery_Internet Explorer 11 - Fatal编程技术网

Javascript Fire document.ready on back按钮IE11

Javascript Fire document.ready on back按钮IE11,javascript,jquery,internet-explorer-11,Javascript,Jquery,Internet Explorer 11,我有一个带有搜索表单的页面。当您第一次访问该页面时,我有一个jQuery(document).ready()启动: 现在,当您提交表单并单击“上一步”按钮时,document.ready不会启动,它需要启动 最初的问题只存在于Firefox中,但经过一些研究,我发现在主体中添加卸载事件解决了以下问题: jQuery(window).unload(function(){}); 现在,我被告知它在IE11中不起作用 有没有人知道如何在IE11中启动document.ready函数的技巧?因此,我在

我有一个带有搜索表单的页面。当您第一次访问该页面时,我有一个jQuery(document).ready()启动:

现在,当您提交表单并单击“上一步”按钮时,document.ready不会启动,它需要启动

最初的问题只存在于Firefox中,但经过一些研究,我发现在主体中添加卸载事件解决了以下问题:

jQuery(window).unload(function(){});
现在,我被告知它在IE11中不起作用

有没有人知道如何在IE11中启动document.ready函数的技巧?

因此,我在搜索时无意中发现了它,就埋在了帖子的底部

我试了一下,效果很好:

// break the bfcache (ie11 and all others likely)
jQuery(window).focus(
  function() {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);
我保持了原始代码的完整性,因为在我的例子中,我只是设置了一个unix时间戳,如果它发生多次就可以了

完整答案:

jQuery(document).ready(
  function () {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);

jQuery(window).unload(function(){});

jQuery(window).focus(
  function() {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);
所以,我在寻找的过程中偶然发现,被埋在柱子的底部

我试了一下,效果很好:

// break the bfcache (ie11 and all others likely)
jQuery(window).focus(
  function() {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);
我保持了原始代码的完整性,因为在我的例子中,我只是设置了一个unix时间戳,如果它发生多次就可以了

完整答案:

jQuery(document).ready(
  function () {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);

jQuery(window).unload(function(){});

jQuery(window).focus(
  function() {
    jQuery("#new_search").val(Math.round(new Date().getTime() / 1000));
  }
);

对于遇到此问题的任何其他人,这里有一篇MSDN文章,记录了如何停止IE11的向后/向前缓存行为:。根据这一点,添加beforeunload事件处理程序会停止它。这也适用于Firefox:。

对于遇到此问题的任何其他人,这里有一篇MSDN文章,介绍如何停止IE11的向后/向前缓存行为:。根据这一点,添加beforeunload事件处理程序会停止它。这同样适用于Firefox:。

你在这里使用的是
历史记录。pushState
吗?不,我不知道你在这里使用的是什么
历史记录。pushState
吗?不,我不知道那是什么