[英]Is there a way to debug JavaScript in the iPhone/iOS Safari browser?
I have a strange behavior on the iPhone browser.我在 iPhone 浏览器上有一个奇怪的行为。 Is there a tool to debug the JavaScript of the iPhone browser?有没有调试iPhone浏览器JavaScript的工具?
I'm hoping there's something more advanced than simple alert()
messages.我希望有比简单的alert()
消息更高级的东西。 Is there something with advanced tools like setting breakpoints and viewing object states?是否有一些高级工具,例如设置断点和查看对象状态?
With the release of iOS 6, Apple released Remote Web Inspector for their Mobile Safari, and this is huge.随着 iOS 6 的发布,Apple 为他们的 Mobile Safari 发布了 Remote Web Inspector,这是巨大的。 Basically you have all the features and power of Web Inspector in regular Safari, for your mobile apps, including Phonegap apps.基本上,您拥有常规 Safari 中 Web Inspector 的所有功能和强大功能,适用于您的移动应用程序,包括 Phonegap 应用程序。
I've used weinre but this tool makes it obsolete for newer versions of iOS (unfortunately not for old versions of iOS, non-iOS devices, or if you're on Windows) since its a full-featured debugger with breakpoints and everything.我使用过weinre,但是这个工具使它对于较新版本的 iOS 已经过时了(不幸的是不适用于旧版本的 iOS、非 iOS 设备,或者如果您使用的是 Windows),因为它是一个带有断点和所有功能的全功能调试器。
In Safari 6+ for Mac, access your page from the Develop menu.在 Mac 版 Safari 6+ 中,从“开发”菜单访问您的页面。 You can enable Develop menu in Safari's Advanced Preferences if its not showing up.如果未显示,您可以在 Safari 的高级首选项中启用开发菜单。
More discussion at the bottom of:更多讨论在底部:
http://www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers http://www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers
(Also, if you read about a "secret private interface" or iWebInspector somewhere, these are also made obsolete.) (此外,如果您在某处读到“秘密私有接口”或 iWebInspector,这些也已过时。)
check out weinre or use the remote version debug phonegap .查看weinre或使用远程版本调试 phonegap 。
cu铜
you can also inject firebug using a simple bookmark .您还可以使用简单的书签注入 firebug 。 I've used it on the ipad and my debugging abilities were immensely enhanced.我在 ipad 上使用过它,我的调试能力得到了极大的增强。
I faced a simple use case in which I only needed to test my code on a Safari's JS engine (Merely debugging, simply running it and consuming traces).我遇到了一个简单的用例,其中我只需要在 Safari 的 JS 引擎上测试我的代码(仅仅调试,简单地运行它并使用跟踪)。
To that end I used Epiphany web browser, which is both free and uses JavaScriptCore JS engine which is also used by Safari.为此,我使用了 Epiphany 网络浏览器,它既免费又使用 JavaScriptCore JS 引擎,Safari 也使用它。 Epiphany isn't provided with developer tools, so I used http://jsconsole.com/ to view my traces. Epiphany 未随开发人员工具一起提供,因此我使用http://jsconsole.com/查看我的跟踪记录。
Though it is a thin solution, it helped me find a line which worked on Chrome but didn't on Safari.虽然它是一个简单的解决方案,但它帮助我找到了一条适用于 Chrome 但不适用于 Safari 的产品线。
Step by Step Guide How To Enable JavaScript in iPhone分步指南如何在 iPhone 中启用 JavaScript
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.