Calling Javascript from WinForms WebBrowser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    Calling Javascript from WinForms WebBrowser

    Hi all,
    I have read a few articles on the subject, but I can't get this one to work. I am trying to automate a simple program to press a couple buttons on a webpage. The webpage however has everything in Javascript, so the button I am trying to press has the html tag:
    Code:
    <a href="#" class="send_button" onclick="w(this).call('sendLoad', '27196', 'normal', 5);">Send</a>
    I have worked out it is calling the Javascript function:
    Code:
    w.call('getPage',action,options.form.id)
    That function is in a resource, and not explicitly visible on the html page.

    I have been trying to submit this from C# when loaded in a WebBrowser control using the following:
    Code:
    private object MyInvokeScript(string name, params object[] args)
    		{ 
    			return this.webBrowser.Document.InvokeScript(name, args); 
    		}
    
    		private void CallScripts()
    		{
    			this.MyInvokeScript("w.call", "sendLoad", "27196", "normal", 5);
    		}
    But without any feedback, I have no idea if I'm even on the right track. This is more from my lack of understanding of Javascript, so is there anyone who has done this before, or can see where I am going wrong?
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Nevermind, gave up and spoke to IT. They did what I thought and said I wasn't allowed to do that. Thanks anyway.

    Comment

    Working...