Javascript 如何在 Windows Phone 7 上调试 Internet Explorer?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5198808/
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-08-23 16:08:14  来源:igfitidea点击:

How do I debug Internet Explorer on Windows Phone 7?

javascriptdebugginginternet-explorerwindows-phone-7remote-debugging

提问by singingwolfboy

I'm not a Windows Phone developer, and I want as little to do as possible with anything related to Microsoft. Nonetheless, I need to get my mobile web app running properly on Windows Phone 7. What debugging tools are available for the platform? Something like the Webkit developer tools or Firebug would be ideal, either from the phone itself or more likely, remotely debugging from my computer.

我不是 Windows Phone 开发人员,我希望尽可能少做与 Microsoft 相关的任何事情。尽管如此,我需要让我的移动 Web 应用程序在 Windows Phone 7 上正常运行。该平台有哪些调试工具可用?Webkit 开发人员工具或 Firebug 之类的东西是理想的,无论是从手机本身还是更有可能从我的计算机远程调试。

If such a thing doesn't exist, I'd settle for being able to read Javascript error messages, and view the contents of variables using alert()or similar. At this point, all I know is that my JS is failing: I don't know where or why, let alone how to fix it.

如果这样的东西不存在,我会满足于能够读取 Javascript 错误消息,并使用alert()或类似的方式查看变量的内容。在这一点上,我只知道我的 JS 失败了:我不知道在哪里或为什么,更不用说如何修复它了。

My dev computer is running OS X, and I'd really like to be able to use these tools from OS X if possible. Assuming that debugging tools exist (which I really hope they do) are they designed for Windows only? If so, does anyone know how well they would work with Wineor similar?

我的开发计算机运行的是 OS X,如果可能的话,我真的希望能够从 OS X 使用这些工具。假设存在调试工具(我真的希望他们这样做)它们是否仅适用于 Windows?如果是这样,有没有人知道他们与Wine或类似产品的搭配效果如何?

EDIT: I have a physical Windows Phone 7 device, so I can use that. However, alert()doesn't seem to be working, which is why I'm posting this question. Does alert()normally work on the WP7 browser?

编辑:我有一个物理 Windows Phone 7 设备,所以我可以使用它。但是,alert()似乎不起作用,这就是我发布此问题的原因。是否alert()对WP7浏览器正常工作?

采纳答案by scunliffe

You'll likely find the Mobile Perf Bookmarkletto be the easiest all-in-one tool for testing anymobile device.

您可能会发现Mobile Perf Bookmarklet是用于测试任何移动设备的最简单的多合一工具。

Works well on the iPhone/iPad/Samsung Galaxy Tab in my testing so far.

到目前为止,在我的测试中,在 iPhone/iPad/Samsung Galaxy Tab 上运行良好。

Quote:

引用:

It displays a menu with links that load other bookmarklets including Firebug Lite, Page Resources, DOM Monster, SpriteMe, CSSess, and Zoompf.

它显示一个菜单,其中包含加载其他书签的链接,包括 Firebug Lite、Page Resources、DOM Monster、SpriteMe、CSSess 和 Zoompf。

enter image description here

在此处输入图片说明

回答by Subcreation

Unless you have a Windows Phone 7 device, you will need to run Windows in BootCamp and install the Windows Phone Developer Toolsin order to test in IE on the emulator. I don't know about Whine, but I ran into major problems trying to test in Parallels - so based on my experience, I suggest keeping it as simple as possible.

除非您有 Windows Phone 7 设备,否则您需要在 BootCamp 中运行 Windows 并安装Windows Phone Developer Tools,以便在模拟器上的 IE 中进行测试。我不知道 Whine,但我在尝试在 Parallels 中进行测试时遇到了重大问题 - 所以根据我的经验,我建议尽可能保持简单。

There is no console in IE on the phone, so you will need to use alert, like you suggested, or just write text to a div on your page as a custom console.

手机上的 IE 中没有控制台,因此您需要像您建议的那样使用警报,或者只是将文本写入页面上的 div 作为自定义控制台。

If you really want to code in OS X (which I definitely understand), using a separate machine for testing IE in the WP7 emulator is going to be your best bet.

如果你真的想在 OS X 中编码(我绝对理解),使用单独的机器在 WP7 模拟器中测试 IE 将是你最好的选择。

EDIT:I just tested alert and it did work fine on my Windows Phone. My guess is that a syntax error is preventing it from calling.

编辑:我刚刚测试了警报,它在我的 Windows Phone 上运行良好。我的猜测是语法错误阻止它调用。

回答by Sergei Grebnov

The following may be interesting

以下内容可能很有趣

Simple IE debug tool for Windows Phone

适用于 Windows Phone 的简单 IE 调试工具

Supports

支持

  • Html traversing
  • Html node styles, properties, metrics
  • Reading console output
  • Executing js on device side from console (including intellisense)
  • Dynamic script injection - ability to debug live sites
  • html遍历
  • Html 节点样式、属性、指标
  • 读取控制台输出
  • 从控制台在设备端执行 js(包括智能感知)
  • 动态脚本注入 - 调试实时站点的能力

Not supported

不支持

  • js breakpoints
  • js断点

回答by Charles Morris - MSFT

Just wanted to add a note to say that full JavaScript debugging is possible now with Windows Phone 8.1 and Visual Studio 2013 Update 2. Full details are available at:

只是想添加一个注释,说明现在可以使用 Windows Phone 8.1 和 Visual Studio 2013 Update 2 进行完整的 JavaScript 调试。完整详细信息可在以下位置获得:

http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/04/diagnosing-mobile-website-issues-on-windows-phone-8-1-with-visual-studio.aspx

http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/04/diagnosing-mobile-website-issues-on-windows-phone-8-1-with-visual-studio.aspx

I realize that this doesn't help the versions referenced in the original question (WP7), but I'm hoping this will help people who may find this question and are running a more recent version.

我意识到这对原始问题(WP7)中引用的版本没有帮助,但我希望这会帮助那些可能发现这个问题并正在运行更新版本的人。

回答by wheresrhys

I'm using this hack to have console.log send info back to the server (it uses window.fetch, which I'm polyfilling, but could use xhr instead) https://gist.github.com/wheresrhys/bf93057ee3a594454582

我正在使用这个 hack 让 console.log 将信息发送回服务器(它使用 window.fetch,我正在 polyfilling,但可以使用 xhr 代替)https://gist.github.com/wheresrhys/bf93057ee3a594454582

回答by Valdez V.

Something that has worked for me, is to test my mobile pages through the Windows Vista built-in Internet Explorer browser. It comes with a script debugger ( which you have to enable in Advanced Options tab through the Internet Options menu ), and it seems that it gets really close to the Internet Explorer Mobile implementation.

对我有用的是通过 Windows Vista 内置的 Internet Explorer 浏览器测试我的移动页面。它带有一个脚本调试器(您必须通过 Internet 选项菜单在高级选项选项卡中启用它),而且它似乎非常接近 Internet Explorer Mobile 的实现。

Another tip would be, that, instead of using window.alerts, you can also use document.write or set output to a div content.

另一个提示是,除了使用 window.alerts,您还可以使用 document.write 或将输出设置为 div 内容。