简体   繁体   English

有没有办法在 iPhone/iOS Safari 浏览器中调试 JavaScript?

[英]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),因为它是一个带有断点和所有功能的全功能调试器。

Requirements:要求:

  1. A Mac with Safari 6+带有 Safari 6+ 的 Mac
  2. Either a USB-attached iOS 6+ device or xCode 4.5+ running an iOS 6+ simulator连接 USB 的 iOS 6+ 设备或运行 iOS 6+ 模拟器的 xCode 4.5+

How to activate the inspector:如何激活检查器:

  1. In your simulator or device, open Settings > Safari > Advanced > Web Inspector > On在您的模拟器或设备中,打开设置 > Safari > 高级 > Web Inspector > On
    (this is on by default in the simulator) (这在模拟器中默认开启)
  2. 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 的高级首选项中启用开发菜单。

    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

  1. Open your iPhone settings.打开您的 iPhone 设置。
  2. Tap on safari in the app list.在应用列表中点击 safari。
  3. Tap on Advanced option.点击高级选项。
  4. Enable Javascript iPhone with the help of switch push.在开关推送的帮助下启用 Javascript iPhone。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于从非默认iOS浏览器在Safari中打开iPhone的JavaScript - JavaScript for iPhone to open in Safari from non-default iOS browser iPhone / iOS 6 / Mobile Safari:有没有办法检测“浏览器全屏”模式? Android兼容性? - iPhone/iOS 6/Mobile Safari: Is there a way to detect “in browser fullscreen” mode? Android compatibility? Javascript如何在iOS上的Safari中确认浏览器关闭 - Javascript how to confirm browser close in Safari on iOS 在 iOS 中,有没有办法检测 web 页面是否加载了 SFSafariViewController 与普通的 Safari 浏览器使用 Z4A9E13B6ACAAAF755 - in iOS, is there a way to detect if a web page is loaded with SFSafariViewController vs the normal Safari Browser using Javascript? 在Safari浏览器中的javascript中访问相机的方法 - A way to access camera in javascript in safari browser 在iPhone应用程序上调试Javascript的最佳方法? - Best way to debug Javascript on an iPhone app? 如何调试移动网站无法正常工作,和/或为Safari浏览器添加JavaScript polyfill? - How to debug mobile website not working, and/or add javascript polyfill for safari browser? 使用JavaScript在iPhone Safari浏览器上自动缩小 - Zoom out automatically on iPhone safari browser using javascript Safari Web Inspector不会在iOS 7 Simulator中调试JavaScript - Safari Web Inspector doesn't debug JavaScript in iOS 7 Simulator Facebook评论导致iPhone和iOS Safari浏览器出现JavaScript错误 - Facebook comments results in javascript error in Safari for iPhone and iOS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM