javascript 不适用于本机 Android 浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17595646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 08:55:05  来源:igfitidea点击:

javascript not working on native android browser

javascriptandroidmobile

提问by Jez D

I am part way through developing a mobile web app which contains almost no HTML elements. JSON2HTML is used to create HTML elements.

我正在开发一个几乎不包含 HTML 元素的移动网络应用程序。JSON2HTML 用于创建 HTML 元素。

My problem is that it works ok exceptfor on

我的问题是,它工作的很好,除了

  • iPad
  • Android 4.0.3 Native browser.
  • iPad
  • Android 4.0.3 本机浏览器。

The problem with these browsers is that the content isn't being rendered.

这些浏览器的问题在于没有呈现内容。

It works fine on

它工作正常

  • Android 4.0.3 Chrome,
  • Android 4.0.3 Firefox
  • Android 4.0.3 Opera
  • Android 4.0.3 Dolphin
  • Android 4.1.1 Native
  • Android 4.1.1 Other browsers
  • 安卓 4.0.3 铬,
  • 安卓 4.0.3 火狐
  • 安卓 4.0.3 歌剧
  • 安卓 4.0.3 海豚
  • 安卓 4.1.1 原生
  • Android 4.1.1 其他浏览器

Just to clarify, this is a mobile web app, not a native mobile app. I am not using any native code, I am using standard web technologies (HTML5, CSS3, jQuery, Javascript, JSON)

澄清一下,这是一个移动网络应用程序,而不是一个本地移动应用程序。我没有使用任何本机代码,我使用的是标准 Web 技术(HTML5、CSS3、jQuery、Javascript、JSON)

采纳答案by Jez D

After days of research and testing, I have found the solution.

经过几天的研究和测试,我找到了解决方案。

  1. First I activated the built-in debugger on my Android phone - instructions at http://tinyurl.com/768qltl
  2. The debugger then told me that the error was at line 71 of jquery.json2html.js
  3. I opened jquery.json2html.js
  4. I replaced line 71 with the following code
    else $.fn.append.call($(this),$(dom).children());
  1. 首先,我在我的 Android 手机上激活了内置调试器 - http://tinyurl.com/768qltl 上的说明
  2. 然后调试器告诉我错误在 jquery.json2html.js 的第 71 行
  3. 我打开了 jquery.json2html.js
  4. 我用以下代码替换了第 71 行
    else $.fn.append.call($(this),$(dom).children());

This works because the previous line 71 was calling the jquery append.apply function, which only works with specific data type on older browsers.

这是有效的,因为前一行 71 正在调用 jquery append.apply 函数,该函数仅适用于旧浏览器上的特定数据类型。

回答by Nick Davis

Your best bet would be finding a way to remotely debug what's happening in the native browser. There are a couple ways to do this.

最好的办法是找到一种方法来远程调试本机浏览器中发生的事情。有几种方法可以做到这一点。

  • Install an app like JsHybugger, which acts as a reverse proxy
  • Add some new JavaScript to the source page and use Weinre, JSConsole, or to attach remotely
  • 安装一个像JsHybugger这样的应用,它充当反向代理
  • 向源页面添加一些新的 JavaScript 并使用WeinreJSConsole或远程附加