javascript - 微信自带浏览器 reload()方法“失效”
阿神
阿神 2017-04-10 18:11:25
[JavaScript讨论组]
<body>
        <p id="p1">
            qwe
        </p>
        <button id="btn1">bbb1</button>
        <button id="btn2">bbbb2</button>
    </body>
    <script type="text/javascript">
        document.getElementById("btn1").onclick=function(){
            document.getElementById("p1").innerText="123"
        }
        document.getElementById("btn2").onclick=function(){
            window.location.reload();
        }
    </script>

更改过内容后,刷新还是修改后内容,除了微信都没这问题,除非关闭网页重新打开。用fidder看一下根本没有刷新。
有什么好的解决方式。

我目前方法是用location.href=''后面加上时间戳。

阿神
阿神

闭关修行中......

全部回复(3)
PHP中文网

目前是没办法解决reload()方法的,因为微信引擎是不能使用这个方法的,目前多数是用的href链接认为点击

PHPz

location.reload();
我项目中使用这个方法没有问题啊,难道是兼容问题?

ringa_lee

这个是可以解决的 使用 window.location.href="window.location.href+随机数" 解决
我是这样解决的
<p class="Page">
<ul class="PageUl">

<li class="PageLi">
    <a onclick='aa()'  style='text-decoration:underline;color:#00d'>◀返回</a>
 </li>

</ul>
</p>
<script type="text/javascript">

    function aa(){
        var curLocation = window.location.href;
        var number = Math.round(Math.random()*100);
        if(curLocation.indexOf('CorpEMpCheck?') > -1){
            window.location.href = curLocation.substring(0,curLocation.length-3) + '?'+number;
        }else{
            window.location.href = curLocation + '?'+number;
        }
    }

</script>

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号