Map*_*rja 9 html javascript jquery cross-browser mobile-safari
我注意到,我的iphone5上有safari
$(window).resize()
Run Code Online (Sandbox Code Playgroud)
它奇怪地工作......
我有这个代码:
$(document).ready(function () {
$(window).resize(function() {
avviaChart();
initialize();
if($('#time').is(':checked')){
$("#time").removeAttr('checked');
$("#Time").css('border','2px solid #ffffff');
}
});
});
Run Code Online (Sandbox Code Playgroud)
这个代码应该只在窗口大小改变时工作....与其他浏览器工作非常好,但是如果我滚动页面(并且窗口的大小不变),使用safari代码也可以工作...
怎么可能?吴
Riz*_*kel 17
这是iOS6 Safari中发生的已知错误.滚动时,resize事件会随机触发.幸运的是,这不是一个jQuery问题.
对于懒惰:
3Stripe发布了你应该"存储窗口宽度并检查它是否已实际更改,然后继续使用$(window).resize函数"
他的代码片段:
jQuery(document).ready(function($) {
/* Store the window width */
var windowWidth = $(window).width();
/* Resize Event */
$(window).resize(function(){
// Check if the window width has actually changed and it's not just iOS triggering a resize event on scroll
if ($(window).width() != windowWidth) {
// Update the window width for next time
windowWidth = $(window).width();
// Do stuff here
}
// Otherwise do nothing
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12554 次 |
| 最近记录: |