【问题标题】:window.reload() doesn't reload my pagewindow.reload() 不会重新加载我的页面
【发布时间】:2017-01-28 17:04:21
【问题描述】:
     function theLast(){

             if (document.getElementById('dont').checked) {
             document.getElementById('dont').checked=false;}
             else if(document.getElementById('know').checked){
                 document.getElementById('know').checked=false;}
             else if(document.getElementById('master').checked){

                 document.getElementById('master').checked=false;}
                 else {
                 document.getElementById('ans').reset();}
      document.getElementById("pop2").style.display = 'none';
       document.getElementById("myPopup").style.display = 'none';
       document.getElementById("pop3").style.display = 'none';


        document.getElementById("pop4").style.display = 'block';
         document.getElementById('pop4').style.position = "absolute";
         document.getElementById('pop4').style.top = '250px';
        document.getElementById('pop4').style.left = '250px';
        setTimeout(function(){
        document.getElementById('pop4').className = 'waa';

   }, 2500);



window.location.reload();


 }

我想在这个函数结束时重新加载我的页面 试过 window.location.reload() location.reload(true)

有没有其他方法可以重新加载我的页面?

【问题讨论】:

  • 1.清理你的代码。 2. 我在你的代码中找不到window.reloadwindow.location.reload(这是正确的)。
  • 我在代码中没有看到您调用 window.location.reload 的任何地方。这可能就是它不起作用的原因。
  • “从当前 URL 重新加载资源”。见location.reload()
  • 启动你的调试器,在window.location.reload 行放置一个断点。确保它到达那里。然后越过线。您的浏览器将重新加载。最有可能的是,您会发现控件永远不会到达那条线,因为您的逻辑中存在其他错误。

标签: javascript reload


【解决方案1】:

我不确定是否支持location.reload,但你为什么不试试这个:

window.location.href = window.location.href;

【讨论】:

  • 你确定什么?
  • 什么意思?
  • 抱歉,我的意思是“你不确定什么?”。
  • 该方法的浏览器支持。在这里工作,但我不知道 OP 的浏览器,因为location.reload() 应该按照这个工作:developer.mozilla.org/en-US/docs/Web/API/Window/location
  • window.reload 不是函数
【解决方案2】:
$('#something').click(function() {
location.reload();
});

将此添加到您的脚本中

【讨论】:

  • 为什么我需要把它包装在setTimeout中?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-30
  • 2018-11-30
  • 2020-06-22
  • 2013-01-31
  • 1970-01-01
  • 2016-06-08
  • 1970-01-01
相关资源
最近更新 更多