简体   繁体   English

按下后退按钮时重新加载页面(移动设备,野生动物园)

[英]Reload page on back button press (mobile, safari)

so i've been looking around and i've found several questions which are all very similar to this with fixes however none have worked for me because I think they may be outdated. 所以我一直到处走走,我发​​现了几个与修复程序非常相似的问题,但是没有一个对我有用,因为我认为它们可能已经过时了。

This is my code: 这是我的代码:

 $(document).ready(function() { $('body').css('display', 'none'); $('body').fadeIn(5000); $('.link').click(function(event) { event.preventDefault(); newLocation = $(event.currentTarget).find('a').attr('href'); $('body').fadeOut(1000, function () { newpage(newLocation); }); }); function newpage(location) { console.log(location); window.location = location; window.onunload = function(){}; } }); 

Everything seems to work fine on desktop browsers however the issue is only on mobile. 一切似乎在桌面浏览器上都可以正常运行,但是问题仅在移动设备上。 What im asking is how can I refresh the page on the click of the back button so the animations play each time a page is loaded and left. 我要问的是如何单击后退按钮刷新页面,以便每次加载和离开页面时都播放动画。

You can see what I mean here - website 您可以在这里看到我的意思- 网站

Haven't tested this on mobile but I know this works on my laptop browser. 尚未在移动设备上对此进行测试,但是我知道它可以在我的笔记本电脑浏览器上运行。

<script>
    $(document).ready(function(e) {
        var $input = $('#refresh');
        $input.val() == 'yes' ? location.reload(true) : $input.val('yes');
    });
</script>

<input type="hidden" id="refresh" value="no">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM