我可以以平台中立的方式查询无 URL 栏的移动 Safari 窗口高度吗?
我正在编写一个小型横向滚动文本阅读器小部件,类似于您在 iPhone 应用程序商店中获得的小部件,其中应用程序的屏幕截图面板是嵌入在主垂直滚动面板中的不同的水平滚动面板。
在所有版本(包括全分辨率键盘/鼠标计算机样式)中,面板占据容器宽度的 100%,因此它就像跨页面的水平条纹。
在小分辨率触摸界面版本中,即针对智能手机,我希望它也能够调整大小以达到窗口的完整高度,以便当您垂直滚动到它时,它可以占据整个屏幕。
iPhone 使这变得棘手,因为 $(window).height() 或您想要查询它的方式似乎取决于 URL 栏是否可见。
无需对代码进行特殊处理来了解它是否在 iPhone 上,或者添加一些技巧来滚动窗口以关闭 URL 栏,然后查询高度,有没有办法询问 Safari 移动版“窗口高度是多少”在我的 3GS 上,无论 URL 栏当前是否可见,都会产生 416 的答案?
我想找到一种与平台无关的方式来询问所有主要智能手机,“我可以将此面板设置为多高,以便当您滚动到它时,它会填充整个浏览器窗口?”
谢谢,我已经为此苦苦挣扎了一段时间,并且已经在这里进行了挖掘,但找不到这个具体信息。
I'm writing a little side-scrolling text reader widget similar to what you get in the iPhone app store where the panel of screenshots for an app is this different, horizontally-scrolling panel embedded within the main vertically-scrolling panel.
In all versions (including full-res keyboard/mouse computer style) the panel takes up 100% of the width of the container, so it's like a horizontal stripe across the page.
In the small-res touch-interface version, i.e. for smartphones, I want it to also resize to be the full height of the window so that when you scroll vertically to it, it can take up the full screen.
The iPhone makes this tricky because the $(window).height() or however you want to query it seems to depend on whether or not the URL bar is visible.
Without special-casing the code to know if it's on an iPhone, or adding in hacks to scroll the window to get the URL bar off and then query the height, is there a way to ask Safari mobile, "what's the window height" that will yield, on my 3GS, an answer of 416 regardless of whether the URL bar is currently visible or not?
I want to find a platform-neutral way to ask, for all major smartphones, "what height can I set this panel to so that when you scroll to it, it fills the whole browser window?"
Thanks, been beating my head against this for a while and already dug around on here and couldn't find this specific info.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也在寻找解决方案。没有成功。我最终遇到了像你实际上想避免的那样的黑客行为。但由于似乎没有其他解决方案,我想我将细节留在这里:
在我的情况下,页面只包含一个带有一个图像的图层,该图像应该与视口允许的一样大,保持原始的宽高比。所以我有一个在加载和方向更改时调用的函数,它是这样的:
}
I was looking for a solution to this also. No success. I ended up with a hack like you actually wanted to avoid. But as there seems to be no other solution around, I thought I leave the details here:
In my case the page contains nothing but a layer with one image that ought to be as big as the viewport allows, keeping the original aspect ratio. So I have a function I call on load and oriantation-change and it goes like this:
}