views:

575

answers:

4

I'm using the WebBrowser control and mshtml.dll. When I simulate click on link <a href='..'>..</a>, the WebBrowser shows a JavaScript warning dialog:

Unable to move the focus to the element as it is in the invisible ,off or can't have a focus.

The code I use to simulate the click:

anchor.click();

...where anchor has the type: HTMLAnchorElementClass

So I want to disable all JavaScript warnings in my component WebBrowser. How might I do this?

A: 

You have to find the place where you are doing anchor.click(); and either remove it or replace it with if(anchor.clientHeight != 0){anchor.click();}.

voyager
A: 

It's possible to work around this particular warning by having the link element be part of the page and visible.

Calling the click() method actually does more than execute an onclick handler and navigate the browser, it also focuses the element - just like when a real click happens. If the element is offscreen, this behavior is not possible.

Simply attach the link to the body to not have this warning show up.

levik
can u give me example code..
goodman
A: 

Ok How off all javascript warning in Browser?

goodman
A: 

I'm not sure if your referring to the windows forms WebBrowser control but it has the ScriptErrorsSuppressed property for disabling script error messages.

Phaedrus