24

IE10 在 HTML5 合规性方面有一些出色的增强,但在 WP8 上运行时仍然无法开发 JavaScript HTML5,因为除了控制台消息之外无法调试应用程序。

在 WP8 上运行的 IE10 是否可以像 WebKit 手机浏览器一样提供远程调试体验(例如,请参阅我在http://www.youtube.com/watch?v=GNAjzFpNEj4上的视频)。当使用 USB 电缆连接到桌面 Safari 时,在 IOS 上调试 Javascript 应用程序很容易,因为可以设置断点并在远程调试器中检查变量。我希望 IE10 中也有相同的功能,并希望了解有关在何处启用这些非常需要的功能的任何信息。

4

3 回答 3

22

The bad news, that there is no new debug capabilities in comparison to WP7/IE9. Please take a look on How do I debug Internet Explorer on Windows Phone 7? since we are in exactly the same situation on WP8.

What I personally use on daily basis

  1. Debug your app in IE10 Desktop as much as possible

  2. Weinre remote debugger. Demo video. You can use the following app based on Weinre to simplify its usage (no local setup needed) - IeMobileDebugger src or link to Store

    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

    Not supported

    js breakpoints

  3. For javascript line by line debugging use aardwolf. Demo with VS integration.

  4. To redirect console trace to Visual Studio output and be able to use console.log("some message") for tracing

index.html:

<script type="text/javascript">
    window.console = {
        log: function (str) { window.external.Notify(str); }
    };

    // output errors to console log
    window.onerror = function (e) {
        console.log("window.onerror ::" + JSON.stringify(e));
    };

    console.log("Installed console !");
</script>

MainPage.xaml.cs

private void Browser_Loaded(object sender, RoutedEventArgs e)
{
    Browser.IsScriptEnabled = true;
    // Add your URL here
    Browser.Navigate(new Uri(MainUri, UriKind.Relative));

    Browser.ScriptNotify += (s, arg) =>
    {
        Debug.WriteLine(arg.Value);
    };           
}
于 2013-01-28T19:36:34.280 回答
17

FWIW:Windows Phone 8.1 终于支持远程调试了。请参阅http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/04/diagnosing-mobile-website-issues-on-windows-phone-8-1-with-visual-studio.aspx

于 2014-05-19T15:15:33.937 回答
0

虽然不是一个完整的解决方案,但 Lauri Piispanen 的consolelog.js是一个基于 nodejs 的远程 JS 控制台记录器,可以为您提供帮助。

于 2013-12-26T16:19:41.707 回答