仅使用JavaScript一次重新加载HTML页面

| 如何仅重新加载HTML基本网页一次?我在body标签中使用功能为
onLoad
history.go(0);
,但我只想运行一次。请记住,我使用的是
iframe
,因此无法使用以下类型的代码:
<script language=\" JavaScript\" ><!--
function MyReload()
{
window.location.reload();
}
//--></script>

<Body onLoad=\" MyReload()\" > 
上面的代码对我不起作用 但是下面的代码工作正常,但问题是我需要将其加载一次
<BODY BGCOLOR=#FFFFFF background=\"../images/Index_04.jpg\" onLoad=\"history.go(0)\" >
注意:当用户单击主页链接时,我正在使用2个iframe,而在iframe中加载的页面比我想用当前iframe页面重新加载整个页面要多。     
已邀请:
        您可以在页面网址的末尾使用“ 5”(例如?r),并在重定向之前检查它,就好像重定向已经存在一样。
if(window.location.href.substr(-2) !== \"?r\") {
  window.location = window.location.href + \"?r\";
}
免责声明:我同意其他人的看法,您可能有更好的解决方案-永远不需要刷新“仅一次”。 使用说明 在页面底部,ѭ7上方,您应该输入:-
<script type=\"text/javascript\">
   if(window.location.href.substr(-2) !== \"?r\") {
      window.location = window.location.href + \"?r\";
    }
</script>
而已。     
        
 <script type=\"text/javascript\">
        $(document).ready(function(){

            //Check if the current URL contains \'#\' 
            if(document.URL.indexOf(\"#\")==-1)
            {
                // Set the URL to whatever it was plus \"#\".
                url = document.URL+\"#\";
                location = \"#\";

                //Reload the page
                location.reload(true);

            }
        });
    </script> 
由于if条件,该页面将仅重新加载一次。希望这会有所帮助。     
        我能想到的唯一方法是使用Cookie(或者如果您在正确的平台上使用会话)并在第一次重新加载时进行标记,则在这种情况下变量也可能起作用,因为我们所说的是IFRAME ,但我从未尝试过这种方法。     
        这是另一个使用localStorage对我有效的解决方案。在此解决方案中,我们不需要修改现有的url。
<script type=\'text/javascript\'>
 (function()
 {
  if( window.localStorage ){
    if(!localStorage.getItem(\'firstReLoad\')){
     localStorage[\'firstReLoad\'] = true;
     window.location.reload();
    } else {
     localStorage.removeItem(\'firstReLoad\');
    }
  }
 })();
</script>
    

要回复问题请先登录注册