javascript 网页崩溃 Android 浏览器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8764852/
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
Web Page Crashing Android Browsers
提问by Jargs
Can anyone help me figure out why this page causes Android browsers to crash?
谁能帮我弄清楚为什么这个页面会导致 Android 浏览器崩溃?
All sub-pages seem to work just fine, but when I load the home page on an Android, the browser app just closes without any warning or error messages. I've tried this on 3 Android phones and on a Kindle Fire.
所有子页面似乎都工作正常,但是当我在 Android 上加载主页时,浏览器应用程序只是关闭而没有任何警告或错误消息。我已经在 3 部 Android 手机和 Kindle Fire 上尝试过这个。
When I completely disable JavaScript in the browser on the phone, the page loads successfully. Unfortunately this is a live website, so I'd prefer to save disabling chunks of JavaScript on the server side as a last resort.
当我在手机浏览器中完全禁用 JavaScript 时,页面加载成功。不幸的是,这是一个实时网站,所以我更愿意在服务器端保存禁用 JavaScript 块作为最后的手段。
On a side note, Opera Mini, Opera Mobile and Firefox on an Android phone do not crash, but Dolphin, Miren and the stock browser do.
附带说明一下,Android 手机上的 Opera Mini、Opera Mobile 和 Firefox 不会崩溃,但 Dolphin、Miren 和股票浏览器会。
UPDATE: It appears that I spoke too soon when I said this was fixed. I was able to reduce how often the browser crashes, but it still does occasionally crash when the page is loaded. :(
更新:当我说这是固定的时,我似乎说得太早了。我能够减少浏览器崩溃的频率,但在加载页面时它仍然偶尔会崩溃。:(
UPDATE #2: It now appears that the crash may be CSS related. After spending weeks enabling and disabling various JavaScript snippits, I tried disabling the stylesheet, and now I can't get it to crash.
更新 #2:现在看来崩溃可能与 CSS 相关。在花了数周时间启用和禁用各种 JavaScript 代码段后,我尝试禁用样式表,但现在我无法让它崩溃。
Anyone know of an Android CSS bug that might be causing this? My guess is that it's related to some CSS that only gets accessed after the JavaScript does it's work.
有人知道可能导致此问题的 Android CSS 错误吗?我的猜测是它与一些 CSS 相关,这些 CSS 只能在 JavaScript 工作后才能访问。
采纳答案by Jargs
I found the culprit... It appears that a css font-family rule was to blame. Although, I'm not sure why since the same font stack is used several other places on the site. :\
我找到了罪魁祸首……看来应该归咎于 css font-family 规则。虽然,我不知道为什么,因为网站上的其他几个地方使用了相同的字体堆栈。:\
Here's the line that caused the problem...
这是导致问题的行...
.Site-Search .Buttons input
{
...
font-family: TeXGyreHerosRegular, Arial, "Helvetica Neue", Helvetica, sans-serif;
...
}
For whatever reason that line caused all stock Android browsers to crash. Weird.
无论出于何种原因,该行导致所有股票 Android 浏览器崩溃。奇怪的。
回答by pxp
Check out Weinre. An explanation can be seen in thisyoutube movie. That way you can debug the Android webkit browser just like the well known Firebug.
查看Weinre。可以在这部youtube 电影中看到解释。这样你就可以像著名的 Firebug 一样调试 Android webkit 浏览器。
In Eclipse's emulator (2.3) it loads fine but has some layout flaws.
在 Eclipse 的模拟器 (2.3) 中,它可以正常加载,但存在一些布局缺陷。
回答by Michael
If anyone came here looking for a possible reason why all of their mobile's different browsers crash after a several seconds when loading a particular website it may be due to the version of jQuery employed.
如果有人来到这里寻找在加载特定网站时所有移动设备的不同浏览器在几秒钟后崩溃的可能原因,这可能是由于使用的 jQuery 版本。
For example, the LG-p690f and HTC Incredible S are some of several Android 2.3.x phones known to have troubles with fade transitions in jQuery 1.8.1 and 1.8.2 due to a browser javascript bug that will cause jQuery's Animation
function to fail at this line:
例如,LG-p690f 和 HTC Incredible S 是一些已知在 jQuery 1.8.1 和 1.8.2 中存在淡入淡出过渡问题的 Android 2.3.x 手机,这是由于浏览器 javascript 错误会导致 jQuery 的Animation
功能在这一行:
percent = 1 - ( remaining / animation.duration || 0 )
If you are the owner of the website you can try upgrading to 1.8.3 (or downgrading to 1.7.x if allowed). Otherwise, you can send an e-mail to the website.
如果您是该网站的所有者,您可以尝试升级到 1.8.3(如果允许,也可以降级到 1.7.x)。否则,您可以向网站发送电子邮件。
Sources:
资料来源:
http://bugs.jquery.com/ticket/12497
http://bugs.jquery.com/ticket/12497