jqModal 在 Mobile Safari 中显示不正确

发布于 2024-07-23 08:46:14 字数 654 浏览 7 评论 0原文

我的网站上有一个 jQModal 窗口,其内容由 Ajax 调用填充。 它在所有桌面浏览器中工作正常,但在 iPhone 上的 Mobile Safari 中失败。

覆盖层和窗口本身显示在页面主体的顶部,而不是覆盖 iPhone 视口。 如果向上滚动,您可以看到窗口和覆盖层的位置与在任何其他浏览器中一样。 这尤其成问题,因为对于 Mobile Safari 的用户来说,一旦他们向下滚动并单击拉起模式窗口,就没有任何响应 - 屏幕上带有模式窗口的部分对用户来说是完全不可见的。

我很确定这是因为 jqModal 在其 CSS 中使用了“position:fixed”,而由于各种原因,它在 iPhone 上是 effd 的。 这是一篇很好的博客文章,描述了原因: http://doctyper.com /archives/200808/fixed-positioning-on-mobile-safari/

我查看了其他一些模式窗口库(例如 BlockUI),它们在 Mobile Safari 中也有同样的问题。 有谁知道如何修改 jqModal js/css 来解决这个问题? 干杯

I have a jQModal window on my site that has its content populated by an Ajax call. It works fine in all of the desktop browsers, but it fails in Mobile Safari on the iPhone.

The overlay and the window itself are displayed on the top of the body of the page, rather than covering the iPhone viewport. If you scroll up, you can see the window and the overlay positioned as in any other browser. This is especially problematic because, for a user of Mobile Safari, once they scroll down and click to pull up the modal window, there is no response whatsoever - the part of the screen with the modal window is completely invisible to the user.

I'm pretty sure this is because jqModal uses "position: fixed" in its CSS, which is effd on the iPhone for various reasons. Here's a good blog post describing why: http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/

I've looked at some of the other libraries for modal windows (such as BlockUI) and they have the same issue in Mobile Safari. Does anyone know how to modify the jqModal js/css to fix this? Cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恏ㄋ傷疤忘ㄋ疼 2024-07-30 08:46:14

这是一种黑客但不错的解决方法。 我看到 jqmodal 将模式放在页面顶部,因此此代码在打开模式后只需滚动到顶部:

 if( navigator.userAgent.match(/iPhone/i) || 
  navigator.userAgent.match(/iPad/i) || 
  navigator.userAgent.match(/iPod/i) ||
  navigator.userAgent.match(/Android/i)){
    $('html, body').animate({scrollTop:0}, 'slow');
 }

中的 open 函数中

我将其添加到jqmodal.js SimpleModal 附带的演示,它们似乎在 iPad/iPhone 上可以正常工作,因此迁移到 iPad/iPhone 将是另一种解决方案:
http://www.ericmmartin.com/projects/simplemodal/

This is sort of a hack but decent work around. I'm seeing jqmodal put the modal at the top of the page, so this code simply scrolls to the top after they open a modal:

 if( navigator.userAgent.match(/iPhone/i) || 
  navigator.userAgent.match(/iPad/i) || 
  navigator.userAgent.match(/iPod/i) ||
  navigator.userAgent.match(/Android/i)){
    $('html, body').animate({scrollTop:0}, 'slow');
 }

I added this to the open function in jqmodal.js

From trying the demos that come with SimpleModal, they seem to work correctly on iPad/iPhone so migrating to that would be another solution:
http://www.ericmmartin.com/projects/simplemodal/

苄①跕圉湢 2024-07-30 08:46:14

也许尝试这样的方法来定位模态 div ?

作者:乔恩·布里斯宾

function showModal() { 
  var win_y = $(window).height(); 
  var scroll_y = $(window).scrollTop(); 
  $("#modal_div").css({ top: scroll_y + "px" }); 
} 

var showTimer = false; 
function maybeShowModal(evt) { 
  if ( showTimer ) { 
    clearTimeout( showTimer ); 
  } 
  showTimer = setTimeout( showModal, 175 ); 
} 

$(window).bind( "scroll", maybeShowModal ); 

Maybe try something like this to position the modal div?

Via Jon Brisbin

function showModal() { 
  var win_y = $(window).height(); 
  var scroll_y = $(window).scrollTop(); 
  $("#modal_div").css({ top: scroll_y + "px" }); 
} 

var showTimer = false; 
function maybeShowModal(evt) { 
  if ( showTimer ) { 
    clearTimeout( showTimer ); 
  } 
  showTimer = setTimeout( showModal, 175 ); 
} 

$(window).bind( "scroll", maybeShowModal ); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文