Hello I want to replicate some button click on site
Button code:
<button type="button" class="btn btn-link btn-xs" onclick="getComponents('188855', '5a0f44a9d70380.12406536');return false;" data-toggle="modal" data-target="#viewMtComponents">View</button>
what this does is opens popup window on current page and display some data(which is not loaded with html file)
This is my code for injection:
public void inject(string a , string b)
{
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement script = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)script.DomElement;
element.text = "getComponents('" + a + "', '" + b + "');";
head.AppendChild(script);
}
But it does absolutely nothing. How can I fix it?
You dont need to append the script. You can use the InvokeScript method as documented here .
Object[] args = new Object[2];
args[0] = (Object)a;
args[1] = (Object)b;
webBrowser1.Document.InvokeScript("getComponents", args);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.