javascript - Debugging in the Windows Phone 7 Emulator browser? - Stack Overflow

I'm trying to test my homemade JavaScript framework in as many browsers as I can find. Today I rea

I'm trying to test my homemade JavaScript framework in as many browsers as I can find. Today I realized that on my Windows puter, I could install the Windows Phone 7 developer tools and test in the emulator.

I did this, and sadly it does not work, but I have no idea how to tell what's going wrong. I don't have any idea how to try and fix it because in a framework, there are 1000 things that could go wrong, and all I have is to guess.

Does anyone know how to debug in the emulator browser, or am I just stuck?

I'm trying to test my homemade JavaScript framework in as many browsers as I can find. Today I realized that on my Windows puter, I could install the Windows Phone 7 developer tools and test in the emulator.

I did this, and sadly it does not work, but I have no idea how to tell what's going wrong. I don't have any idea how to try and fix it because in a framework, there are 1000 things that could go wrong, and all I have is to guess.

Does anyone know how to debug in the emulator browser, or am I just stuck?

Share Improve this question asked May 12, 2011 at 1:54 McKaylaMcKayla 6,9596 gold badges39 silver badges49 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

In order to debug my Javascript, from my Javascript I call:

window.external.notify("Some debug message");

I subscribe to the WebBrowser ScriptNotify event in my XAML, then in my C#:

private static void ScriptNotified(object sender, NotifyEventArgs e)
{
    Debug.WriteLine("Script notified: " + e.Value);
}

This is perfect... I added the Script notifier to my MainPage.xaml.cs file with in the

public partial class MainPage : PhoneApplicationPage
    {

Section and it works like a charme.

I then found this snipit:

  // provide our own console if it does not exist, huge dev aid!
  if(typeof window.console == "undefined")
  {
  window.console = {log:function(str){window.external.Notify(str);}};
  }

      window.onerror=function(e, url, lineNumber)
      {
          console.log("ERROR! : " +url + "(" + lineNumber + ") : " + JSON.stringify(e));
      };

  console.log("Installed console ! ");

here: http://sim4all./blogging/?p=266.. PLEASE note that i have modified the onerror to include line nr and file referance.

this implements a Console.log object and a onerror Message.. It ie really helpfull..

This whole operation is of caurse only needed befor the Cordova layer is loaded.. Then Cordova takes better care of this.

Hope it helps.. Kim

It's pretty tricky to debug JS in the emulator browser. You could use Fiddler for monitoring network traffic. However, at the moment, the IE in WP7 is primarily based on Internet Explorer 7 (with some features ported from IE8). If you framework works with IE7, it should pretty much work on WP7 (although there are some changes in the WP7 browser). The Mango update will bring this to IE 9. They are using the same IE 9 code base as the one on the PC.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743766902a4503642.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信