Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - How do I debug JavaScript in a WebBrowser control?

Reply
 
Old 09-14-2009   #1 (permalink)
John Brock


 
 

How do I debug JavaScript in a WebBrowser control?

I am using Visual Basic 2008 Express to write a Windows Forms
application that displays HTML/JavaScript pages in a WebBrowser
control. (I'm setting the form as the WebBrowser's ObjectForScripting
and calling "window.external.whatever()" from JavaScript when I
want JavaScript to call functions in the app).

Right now it can be very difficult to find bugs in the JavaScript
code. If I set ScriptErrorsSuppressed = False I sometimes get a
helpful popup. Or I can scatter JavaScript alert popups through
the code. But it would be very nice to have a real debugger! So
I'm trying to find out if there are any standard (or even non-standard)
ways to debug JavaScript in this situation.

(Note that I have IE8 installed on my PC. I understand there is
a spiffy new JavaScript debugger that comes with IE8 -- it's part
of the Developer Tools that pop up if I hit F12 while in IE. It
would be very nice to be able to use this to set breakpoints in
pages displayed in the WebBrowser, but there is no obvious way to
do this, as F12 does nothing here).
--
John Brock
jbrock@newsgroup


My System SpecsSystem Spec
Old 09-14-2009   #2 (permalink)
Ralph


 
 

Re: How do I debug JavaScript in a WebBrowser control?

On Sep 14, 3:26*pm, jbr...@newsgroup (John Brock) wrote:
Quote:

> I am using Visual Basic 2008 Express to write a Windows Forms
> application that displays HTML/JavaScript pages in a WebBrowser
> control. *(I'm setting the form as the WebBrowser's ObjectForScripting
> and calling "window.external.whatever()" from JavaScript when I
> want JavaScript to call functions in the app).
>
> Right now it can be very difficult to find bugs in the JavaScript
> code. *If I set ScriptErrorsSuppressed = False I sometimes get a
> helpful popup. *Or I can scatter JavaScript alert popups through
> the code. *But it would be very nice to have a real debugger! *So
> I'm trying to find out if there are any standard (or even non-standard)
> ways to debug JavaScript in this situation.
>
> (Note that I have IE8 installed on my PC. *I understand there is
> a spiffy new JavaScript debugger that comes with IE8 -- it's part
> of the Developer Tools that pop up if I hit F12 while in IE. *It
> would be very nice to be able to use this to set breakpoints in
> pages displayed in the WebBrowser, but there is no obvious way to
> do this, as F12 does nothing here).
> --
> John Brock
> jbr...@newsgroup
try putting the following into your javascript code.

debugger;
My System SpecsSystem Spec
Old 09-14-2009   #3 (permalink)
John Brock


 
 

Re: How do I debug JavaScript in a WebBrowser control?

In article <cab85f56-cbca-465b-a7f7-578c5ae73946@newsgroup>,
Ralph <ralphd42@newsgroup> wrote:
Quote:

>On Sep 14, 3:26*pm, jbr...@newsgroup (John Brock) wrote:
Quote:

>> I am using Visual Basic 2008 Express to write a Windows Forms
>> application that displays HTML/JavaScript pages in a WebBrowser
>> control. *(I'm setting the form as the WebBrowser's ObjectForScripting
>> and calling "window.external.whatever()" from JavaScript when I
>> want JavaScript to call functions in the app).
>>
>> Right now it can be very difficult to find bugs in the JavaScript
>> code. *If I set ScriptErrorsSuppressed = False I sometimes get a
>> helpful popup. *Or I can scatter JavaScript alert popups through
>> the code. *But it would be very nice to have a real debugger! *So
>> I'm trying to find out if there are any standard (or even non-standard)
>> ways to debug JavaScript in this situation.
>>
>> (Note that I have IE8 installed on my PC. *I understand there is
>> a spiffy new JavaScript debugger that comes with IE8 -- it's part
>> of the Developer Tools that pop up if I hit F12 while in IE. *It
>> would be very nice to be able to use this to set breakpoints in
>> pages displayed in the WebBrowser, but there is no obvious way to
>> do this, as F12 does nothing here).
Quote:

>try putting the following into your javascript code.
>
>debugger;
Thanks for the suggestion. I already tried that though (forgot to
mention it), and it doesn't seem to have any effect, at least not
from within a WebBrowser control.

(Interestingly, uncaught exceptions in my VB.NET code don't cause
the program to terminate when they occur as a result of JavaScript
calling a function in the app, so I have to explicitly catch and
display them if I want to see them. I wonder if that means anything?)
--
John Brock
jbrock@newsgroup

My System SpecsSystem Spec
Old 09-14-2009   #4 (permalink)
Scott M.


 
 

Re: How do I debug JavaScript in a WebBrowser control?

It's a bit of a hack, but you could insert a JavaScript alert(); within the
document to display pertinent info helpful for debugging.

-Scott


"John Brock" <jbrock@newsgroup> wrote in message
news:h8m5dq$3p9$1@newsgroup
Quote:

>I am using Visual Basic 2008 Express to write a Windows Forms
> application that displays HTML/JavaScript pages in a WebBrowser
> control. (I'm setting the form as the WebBrowser's ObjectForScripting
> and calling "window.external.whatever()" from JavaScript when I
> want JavaScript to call functions in the app).
>
> Right now it can be very difficult to find bugs in the JavaScript
> code. If I set ScriptErrorsSuppressed = False I sometimes get a
> helpful popup. Or I can scatter JavaScript alert popups through
> the code. But it would be very nice to have a real debugger! So
> I'm trying to find out if there are any standard (or even non-standard)
> ways to debug JavaScript in this situation.
>
> (Note that I have IE8 installed on my PC. I understand there is
> a spiffy new JavaScript debugger that comes with IE8 -- it's part
> of the Developer Tools that pop up if I hit F12 while in IE. It
> would be very nice to be able to use this to set breakpoints in
> pages displayed in the WebBrowser, but there is no obvious way to
> do this, as F12 does nothing here).
> --
> John Brock
> jbrock@newsgroup
>

My System SpecsSystem Spec
Old 09-15-2009   #5 (permalink)
John Brock


 
 

Re: How do I debug JavaScript in a WebBrowser control?

I'm already using alert(), but a real debugger would be extremely
desirable. I'm sure the people doing ASP.NET programming aren't
using alert() -- (which is why I included an ASP.NET newsgroup in
my distribution list) -- but I have no idea if what they are doing
is applicable to me. Maybe if I were using a full version of Visual
Studio, rather than VB Express? But displaying JavaScript in a
WebBrowser control has got to be a fairly common practice, so I'm
really hoping there is something out there I can use.

In article <O1eULDZNKHA.4816@newsgroup>,
Scott M. <s-mar@newsgroup> wrote:
Quote:

>It's a bit of a hack, but you could insert a JavaScript alert(); within the
>document to display pertinent info helpful for debugging.
Quote:

>"John Brock" <jbrock@newsgroup> wrote in message
>news:h8m5dq$3p9$1@newsgroup
Quote:

>>I am using Visual Basic 2008 Express to write a Windows Forms
>> application that displays HTML/JavaScript pages in a WebBrowser
>> control. (I'm setting the form as the WebBrowser's ObjectForScripting
>> and calling "window.external.whatever()" from JavaScript when I
>> want JavaScript to call functions in the app).
>>
>> Right now it can be very difficult to find bugs in the JavaScript
>> code. If I set ScriptErrorsSuppressed = False I sometimes get a
>> helpful popup. Or I can scatter JavaScript alert popups through
>> the code. But it would be very nice to have a real debugger! So
>> I'm trying to find out if there are any standard (or even non-standard)
>> ways to debug JavaScript in this situation.
>>
>> (Note that I have IE8 installed on my PC. I understand there is
>> a spiffy new JavaScript debugger that comes with IE8 -- it's part
>> of the Developer Tools that pop up if I hit F12 while in IE. It
>> would be very nice to be able to use this to set breakpoints in
>> pages displayed in the WebBrowser, but there is no obvious way to
>> do this, as F12 does nothing here).
--
John Brock
jbrock@newsgroup

My System SpecsSystem Spec
Old 09-15-2009   #6 (permalink)
Scott M.


 
 

Re: How do I debug JavaScript in a WebBrowser control?

When you do ASP .NET, you can use Visual Studio .NET and IE to debug client
side code pretty easily. I just don't think that process is applicable to
WinForms apps with embedded browser controls.

Sorry!

-Scott

"John Brock" <jbrock@newsgroup> wrote in message
news:h8orgt$jvh$1@newsgroup
Quote:

> I'm already using alert(), but a real debugger would be extremely
> desirable. I'm sure the people doing ASP.NET programming aren't
> using alert() -- (which is why I included an ASP.NET newsgroup in
> my distribution list) -- but I have no idea if what they are doing
> is applicable to me. Maybe if I were using a full version of Visual
> Studio, rather than VB Express? But displaying JavaScript in a
> WebBrowser control has got to be a fairly common practice, so I'm
> really hoping there is something out there I can use.
>
> In article <O1eULDZNKHA.4816@newsgroup>,
> Scott M. <s-mar@newsgroup> wrote:
Quote:

>>It's a bit of a hack, but you could insert a JavaScript alert(); within
>>the
>>document to display pertinent info helpful for debugging.
>
Quote:

>>"John Brock" <jbrock@newsgroup> wrote in message
>>news:h8m5dq$3p9$1@newsgroup
Quote:

>>>I am using Visual Basic 2008 Express to write a Windows Forms
>>> application that displays HTML/JavaScript pages in a WebBrowser
>>> control. (I'm setting the form as the WebBrowser's ObjectForScripting
>>> and calling "window.external.whatever()" from JavaScript when I
>>> want JavaScript to call functions in the app).
>>>
>>> Right now it can be very difficult to find bugs in the JavaScript
>>> code. If I set ScriptErrorsSuppressed = False I sometimes get a
>>> helpful popup. Or I can scatter JavaScript alert popups through
>>> the code. But it would be very nice to have a real debugger! So
>>> I'm trying to find out if there are any standard (or even non-standard)
>>> ways to debug JavaScript in this situation.
>>>
>>> (Note that I have IE8 installed on my PC. I understand there is
>>> a spiffy new JavaScript debugger that comes with IE8 -- it's part
>>> of the Developer Tools that pop up if I hit F12 while in IE. It
>>> would be very nice to be able to use this to set breakpoints in
>>> pages displayed in the WebBrowser, but there is no obvious way to
>>> do this, as F12 does nothing here).
> --
> John Brock
> jbrock@newsgroup
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to copy text from webbrowser/Frame Control (WPF) .NET General
automating ie or webbrowser control VB Script
is the dotnet 2 webbrowser control based on IE 6 or 7? .NET General
Printint the content of a webbrowser control .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46