javascript 在 android 3.0 中不工作
我在以下链接中找到了一个示例应用程序
http://code.google.com/p/chaek/< /a>
该应用程序是一个 epub 阅读器,monocle 库,其中加载了书籍并用于按每一页进行更改。该应用程序的主要部分基于java脚本代码。
当我在我的 Android 手机中运行代码时,它工作正常,电子书已加载,我可以按页面更改它,当我在 Android 3.1 的三星平板电脑中尝试该应用程序时,书已加载但无法更改它按页进行更改,按章节进行更改。
当我尝试打印一些日志错误时,我仅从我的平板电脑中得到以下行,
[METHOD] void openChapter(chapNo:1)
[CALLBACK_WV] void onPageStarted(view:android.webkit.WebView@40d32f58, url:file:///mnt/sdcard/gisbook/.9789026324710/OEBPS/html/, favicon:null)
[CALLBACK_WV] void onPageFinished(view:android.webkit.WebView@40d32f58, url:file:///mnt/sdcard/gisbook/.9789026324710/OEBPS/html/)
javascript:getTotalPageNum()
javascript:openPageByPercentage(0.0)
Uncaught ReferenceError: getTotalPageNum is not defined at null:1
Uncaught ReferenceError: openPageByPercentage is not defined at null:1
而在 Android 手机中,上述行如下
[CALLBACK_WV] void onPageStarted(view:android.webkit.WebView@44f4a130, url:file:///sdcard/.9789026324710/OEBPS/html/, favicon:null)
[CALLBACK_WV] void onPageFinished(view:android.webkit.WebView@44f4a130, url:file:///sdcard/.9789026324710/OEBPS/html/)
javascript:getTotalPageNum()
javascript:openPageByPercentage(0.0)
[BRIDGE] void setTotalPageNum(page:1)
[METHOD] void selectBookmark()
为什么 Android 手机和平板电脑之间存在如此大的差异,是 Android 平板电脑 ie3.0 中的 webview 问题吗在上面的版本中,
我与代码的作者分享了这个问题,他也无法对此有所了解。
当我在谷歌上搜索这个问题时,我遇到了很多程序员说在 webview 上工作的 java 脚本有问题。我尝试了他们的大部分答案,但没有用。
任何人都可以解释我或弄清楚为什么会出现这样的错误...请
i found a sample app in the following link
http://code.google.com/p/chaek/
The app is an epub reader, monocle library, in which the book is been loaded and it use to change by each page. The main part of the app is based on the java script code.
When i run the code in my android mobiles it is working fine, that the ebook gets loaded and i am able to change it page wise, when i try the app in my Samsung tablet of android 3.1 the book gets loaded but not able to change it pagewise its get changed chapter wise.
When i tried to print some log error, i get the following line only from my tablet
[METHOD] void openChapter(chapNo:1)
[CALLBACK_WV] void onPageStarted(view:android.webkit.WebView@40d32f58, url:file:///mnt/sdcard/gisbook/.9789026324710/OEBPS/html/, favicon:null)
[CALLBACK_WV] void onPageFinished(view:android.webkit.WebView@40d32f58, url:file:///mnt/sdcard/gisbook/.9789026324710/OEBPS/html/)
javascript:getTotalPageNum()
javascript:openPageByPercentage(0.0)
Uncaught ReferenceError: getTotalPageNum is not defined at null:1
Uncaught ReferenceError: openPageByPercentage is not defined at null:1
Whereas in from android mobiles the above lines are as follows
[CALLBACK_WV] void onPageStarted(view:android.webkit.WebView@44f4a130, url:file:///sdcard/.9789026324710/OEBPS/html/, favicon:null)
[CALLBACK_WV] void onPageFinished(view:android.webkit.WebView@44f4a130, url:file:///sdcard/.9789026324710/OEBPS/html/)
javascript:getTotalPageNum()
javascript:openPageByPercentage(0.0)
[BRIDGE] void setTotalPageNum(page:1)
[METHOD] void selectBookmark()
Why such a difference between android mobiles and tablets, is the webview a problem in android tablets ie3.0 and above version
i shared this problem with its author of the code he is also not able to get an idea on this.
When i was googling regarding this i came across lot of programmers saying issue on java script working on webview. i tried out most of their answers but no use.
Can anyone explain me or figure out why such an error... pls
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我得到了完全相同的错误,它只出现在蜂窝和冰淇淋三明治上。在姜饼上效果很好。
我解决这个问题的方法是使用“
”而不是“
I got exactly the same error and it appears only on Honeycomb and Ice Cream Sandwich. On Gingerbread it works fine.
The way I worked around it was to use "
<script src=...></script>
" instead of "<script src=.../>
". I'd never think that this would make a difference, but it does. Seems to be a webkit bug.scriptElement.setAttribute("src", "url('file:///android_asset/" + path + "')");
需要替换为:
scriptElement.setAttribute("src", "file:///android_asset/" + path);
scriptElement.setAttribute("src", "url('file:///android_asset/" + path + "')");
needs to be replaced with this one:
scriptElement.setAttribute("src", "file:///android_asset/" + path);