0

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?

2
  • can someone with enough rep help and rewrite the OP's question to proper english for better clarity Commented Oct 3, 2009 at 15:37
  • 1
    Slightly better now, I hope! :-) Commented Oct 3, 2009 at 15:38

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

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();}.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.