PC Review


Reply
Thread Tools Rate Thread

Call a javascript function via vb.net in a webbrowser control

 
 
Andre Rode
Guest
Posts: n/a
 
      20th Mar 2008
Hi!

Since you could help me fixing my last problem, I would like to demand
your help again.

In summary I'm writing an appliation that remotely controls a website.
It has to login (works), choose the right action (works) and put customer
data (works partially)in some fields.

Now some of these fields are being checked via javascript functions. For
example: is the account and the banking code correct?
This function is called in different ways, for example via the onblur
event of the input type in the html form.

How can I call these functions since a simple webbrowser.GetElementById
("inputid").SetAttribute("value",sAccountNo) won't call the onblur event?
I tried

Me.WebBrowser1.Document.GetElementById("customerForm").InvokeMember
("Blur")
or
Me.WebBrowser1.Document.GetElementById("customerForm").InvokeMember
("Change")
or

Me.WebBrowser1.Document.Forms.Item("customerForm").InvokeMember
(nameofthejsfunction)

but nothing works.


the call of the function is similar to this:

fieldChanged('bankAccountPaymentForm');;return;;A4J.AJAX.Submit
('customerForm:bankAccountPaymentForm:BankPaymentRegion','customerForm',e
vent,{'parameters':{'customerForm:bankAccountPaymentForm:
_id548':'customerForm:bankAccountPaymentForm:_id548'}
,'actionUrl':'/OEWeb/pages/newOrder.jsf'} )

the website is realisied by JavaServerFaces if this could have any
meaning.

Hope you can help me again
Greetings from Germany,
André
 
Reply With Quote
 
 
 
 
\(O\)enone
Guest
Posts: n/a
 
      20th Mar 2008
Andre Rode wrote:
> How can I call these functions since a simple
> webbrowser.GetElementById
> ("inputid").SetAttribute("value",sAccountNo) won't call the onblur
> event? I tried


I have a WebBrowser control in one of my applications, and programmatically
call JavaScript functions using the following code:

\\\
browser.Document.Window.DomWindow.execscript("doSomething(parameters)",
"JavaScript")
///

This is probably different from calling within the context of a control
event, as I suspect things such as the "this" object may be referencing
different things, but perhaps this is enough to get you started..?

HTH,

--

(O)enone


 
Reply With Quote
 
 
 
 
GS
Guest
Posts: n/a
 
      20th Mar 2008
pardon me for jumping in,
is "Javascript" exactly the literal "JavaScript"?

when to use browser.document.invokescript(....) or something similar?

args() as object
' ... setup the args objet
browser.Document.InvokeScript(ScriptName, args)


"(O)enone" <(E-Mail Removed)> wrote in message
news:frtfds$2r3$(E-Mail Removed)...
> Andre Rode wrote:
> > How can I call these functions since a simple
> > webbrowser.GetElementById
> > ("inputid").SetAttribute("value",sAccountNo) won't call the onblur
> > event? I tried

>
> I have a WebBrowser control in one of my applications, and

programmatically
> call JavaScript functions using the following code:
>
> \\\
> browser.Document.Window.DomWindow.execscript("doSomething(parameters)",
> "JavaScript")
> ///
>
> This is probably different from calling within the context of a control
> event, as I suspect things such as the "this" object may be referencing
> different things, but perhaps this is enough to get you started..?
>
> HTH,
>
> --
>
> (O)enone
>
>



 
Reply With Quote
 
\(O\)enone
Guest
Posts: n/a
 
      20th Mar 2008
GS wrote:
> pardon me for jumping in,
> is "Javascript" exactly the literal "JavaScript"?


Yes, exactly that -- sorry, should have made that clearer.

> when to use browser.document.invokescript(....) or something similar?


I don't know about that one, someone else will have to help there...

--

(O)enone


 
Reply With Quote
 
Andre Rode
Guest
Posts: n/a
 
      31st Mar 2008
"\(O\)enone" <(E-Mail Removed)> wrote in news:fru624$lnh$(E-Mail Removed):

> GS wrote:
>> pardon me for jumping in,
>> is "Javascript" exactly the literal "JavaScript"?

>
> Yes, exactly that -- sorry, should have made that clearer.
>
>> when to use browser.document.invokescript(....) or something similar?

>
> I don't know about that one, someone else will have to help there...
>


I just wanted to thank, the hint with
browser.Document.Window.DomWindow.execscript

worked perfectly
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebBrowser control not respecting ‘return false;’ javascript call on links Peter Microsoft Dot NET Framework Forms 1 30th Mar 2010 01:29 PM
Altering JavaScript function via webbrowser ofiras Microsoft C# .NET 9 9th Jun 2009 08:44 PM
webbrowser control: how to capture event of mouse hovering over thelink or mouse click events in webbrowser only? P-GPS Microsoft VB .NET 1 15th Dec 2007 12:31 PM
Call javascript function without using any event call cschang Microsoft ADO .NET 3 1st Feb 2005 04:04 AM
Re: How to call the print function directly from a webbrowser control Herfried K. Wagner [MVP] Microsoft Dot NET Framework Forms 0 11th Aug 2004 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:01 PM.