使用javascript或jquery刷新页面大小 [英] Refresh page on resize with javascript or jquery
本文介绍了使用javascript或jquery刷新页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想强制浏览器在用户调整大小时刷新页面。我有以下代码:
I want to force the browser to refresh the page when the user resizes it. I have following code:
function refresh() { location.reload(); }
<body onResize="refresh()">
但它不起作用。你们中有人有解决方案吗?
谢谢
but it does not work. Does anyone of you has a solution? Thanks
推荐答案
just javascript:
just javascript:
window.onresize = function(){ location.reload(); }
with jquery:
with jquery:
$(window).resize(function(){location.reload();});
或
$(window).on('resize',function(){location.reload();});
这篇关于使用javascript或jquery刷新页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文