System.Windows.Forms.WebBrowser does not launch Javascript

There is a link on the website that I am trying to click programmatically. He worked for a while, and then suddenly stopped. I know, I love these problems, right?

I thought the site had changed a bit, and now I just grabbed the wrong element, but this is not the case.

When I try to manually click a link, nothing happens - this is the odd part for me. It works in IE, Mozilla, Chrome, etc. It seems that javascript just stops working with the webbrowser object.

href: href = "javascript: SomeMethod ('Param1', 'Param2', 'Param3')

Is there any way to say that all javascript is loaded correctly? Is there any parameter I have to set for javascript to work?

Note. I set WebBrowser.ScriptErrorsSuppressed = true since an error occurred on the page in the past.

Thanks!

PS - I’m sorry, they will not allow me to create a web browser or the system.windows.forms.webbrowser tag ... I do not have rep ...

Update Aug 6: I did some reading, and some asked to determine what IE does for this control, which I don't know? There seems to be a way to associate a web browser control with its Windows profile using these Internet permissions instead of the standard ones, which may be the reason that nothing works. I have not yet found how to do this.

+4
source share
1 answer

try it

object[] o = new object[3]; param1[0]=txtMessage.Text; param1[1]=txtMessage.Text; param1[2]=txtMessage.Text; object result = this.webBrowser1.Document.InvokeScript("SomeMethod('Param1', 'Param2', 'Param3')", o); 
0
source

Source: https://habr.com/ru/post/1493945/


All Articles