当某人按下后退按钮或执行后退时,请刷新我的移动页面

时间:2018-03-28 13:22:00

标签: javascript jquery html5

此代码在按回按钮时转发:

<script type = "text/javascript" >
    function preventBack(){window.history.forward();}
    setTimeout("preventBack()", 0);
    window.onunload=function(){null};
</script>

此后退按钮刷新代码适用于iOS但不适用于Android:

<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
    onload=function(){
        var e=document.getElementById("refreshed");
        if(e.value=="no")e.value="yes";
        else{e.value="no";location.reload();}
    }
</script>

所以我想知道的是,我们可以将它们混合在每个操作系统中吗?

我们是否可以实现其中任何一项以防止返回代码以使其刷新?

    window.location.href = window.location.href; //This is a possibility
    window.location.reload(); //Another possiblity
    history.go(0); //And another

0 个答案:

没有答案