如何从 iPhone 中的 javascript 获取滚动宽度
我正在尝试将 epub 文件按章节加载到 web 视图中。我想知道屏幕的宽度。
例如:
if the content have one and half page text means it returns the width to be as 768
but
if the content have two full page text means it returns the width to be as 1536
我的代码是:
int totalWidth = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollWidth"] intValue];
I am trying to load an epub file in chapter wise into the webview. I want to know the width of the screen.
For Example:
if the content have one and half page text means it returns the width to be as 768
but
if the content have two full page text means it returns the width to be as 1536
my code is:
int totalWidth = [[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.scrollWidth"] intValue];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个
[[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth"] intValue];
“document.body.scrollWidth”返回 UIWebView 内容的大小。
Use this
[[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollWidth"] intValue];
"document.body.scrollWidth" returns you size of UIWebView's content.