By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Calling Javascript from WinForms WebBrowser

TheServant
Expert 100+
P: 1,168
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:
Expand|Select|Wrap|Line Numbers
  1. <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:
Expand|Select|Wrap|Line Numbers
  1. 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:
Expand|Select|Wrap|Line Numbers
  1. private object MyInvokeScript(string name, params object[] args)
  2.         { 
  3.             return this.webBrowser.Document.InvokeScript(name, args); 
  4.         }
  5.  
  6.         private void CallScripts()
  7.         {
  8.             this.MyInvokeScript("w.call", "sendLoad", "27196", "normal", 5);
  9.         }
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?
Feb 27 '12 #1
Share this Question
Share on Google+
1 Reply


TheServant
Expert 100+
P: 1,168
Nevermind, gave up and spoke to IT. They did what I thought and said I wasn't allowed to do that. Thanks anyway.
Feb 28 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.