[英]Is it possible to reload a website if the window width is for more than 0.2 seconds under 1000px?
I have some issues width a code and would like to solve a problem with a trick.我在代码宽度上有一些问题,想用技巧解决问题。
The idea would be: The page should reload if the window size is for more than 0.2 seconds smaller than 1000px.这个想法是:如果窗口大小小于 1000px 超过 0.2 秒,则页面应该重新加载。
Here is a beginning:这是一个开始:
var width = $(window).width(); $(window).resize(function() { if (width > 1000 && $(window).width() < 1000) { location.reload(); } else if (width < 1000 && $(window).width() > 1000) { location.reload(); } });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Would be very thankful for help!将非常感谢您的帮助!
$(window).resize(function() {
setTimeout(function() {
if ($(window).width() < 1000) {
location.reload();
}
}, 200);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.