有哪些方法可以在 UIWebView 中调试 Javascript? [英] What are some methods to debug Javascript inside of a UIWebView?

查看:9
本文介绍了有哪些方法可以在 UIWebView 中调试 Javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚为什么使用 Javascript 的东西在 UIWebView 中不起作用.据我所知,没有办法在 XCode 中为 js 文件设置断点.没问题,我会回到 2004 年并使用警报语句——哦,等等,它们似乎也不能在 UIWebView 中工作!

I'm trying to figure out why something with Javascript isn't working inside of a UIWebView. To my knowledge, there is no way to set a breakpoint inside of XCode for a js file. No problemo, I'll just go back to 2004 and use alert statemen-- oh wait they don't seem to work inside of a UIWebView either!

我唯一能想到的就是将我的 HTML 和 JS 文件导出到我的桌面,然后在 Safari 中进行调试.那行得通!但当然,我在 UIWebView 中遇到的错误不会发生在 Safari 中.

The only thing I could think of is by exporting my HTML And JS files to my desktop and then just doing my debugging inside of Safari. And that works! But of course, the bug I'm fighting with in the UIWebView doesn't occur in Safari.

还有其他方法可以在 UIWebView 内部进行调试,或者我可以使用类似于使用老式警报方法的任何技巧吗?

Are there any other ways for debugging inside of a UIWebView, or any tricks that I can use akin to using the old-school alert method?

推荐答案

如果你使用 iOS >= 6 并且你有山狮 (10.8) 或 Safari >= 6,你可以:

If you're using iOS >= 6 and you have mountain lion (10.8) or Safari >= 6, you can just:

  1. 在模拟器中打开应用程序(或在 XCode >= 4.5.x 中打开您的设备).
  2. 打开 Safari(转到 Preferences -> Advanced 并确保Show Develop Menu in Menubar"处于开启状态.
  3. 从(Safari 的)菜单栏选择 Develop ->iPhone 模拟器 ->[您的网页浏览页面].
  1. Open the application in the simulator (or your device in XCode >= 4.5.x).
  2. Open Safari (go to Preferences -> Advanced and make sure "Show Develop Menu in Menubar" is on.
  3. From the Menu-bar (of Safari) select Develop -> iPhone Simulator -> [your webview page].

就是这样!

这篇关于有哪些方法可以在 UIWebView 中调试 Javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆