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

Discussion in 'Microsoft VB .NET' started by Andre Rode, Mar 20, 2008.

  1. Andre Rode

    Andre Rode Guest

    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é
     
    Andre Rode, Mar 20, 2008
    #1
    1. Advertisements

  2. Andre Rode

    \(O\)enone Guest

    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
     
    \(O\)enone, Mar 20, 2008
    #2
    1. Advertisements

  3. Andre Rode

    GS Guest

    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" <> wrote in message
    news:frtfds$2r3$...
    > 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
    >
    >
     
    GS, Mar 20, 2008
    #3
  4. Andre Rode

    \(O\)enone Guest

    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
     
    \(O\)enone, Mar 20, 2008
    #4
  5. Andre Rode

    Andre Rode Guest

    "\(O\)enone" <> wrote in news:fru624$lnh$:

    > 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
     
    Andre Rode, Mar 31, 2008
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    ASP.net Call Server Side Coce via javascript

    Guest, May 13, 2005, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    191
    Yunus Emre ALPÖZEN [MCAD.NET]
    May 13, 2005
  2. kal
    Replies:
    1
    Views:
    561
    Newbie Coder
    Apr 17, 2007
  3. P-GPS
    Replies:
    1
    Views:
    1,515
    kimiraikkonen
    Dec 14, 2007
  4. Andre Rode
    Replies:
    0
    Views:
    842
    Andre Rode
    Mar 31, 2008
  5. John Brock

    How do I debug JavaScript in a WebBrowser control?

    John Brock, Sep 14, 2009, in forum: Microsoft VB .NET
    Replies:
    5
    Views:
    756
    Scott M.
    Sep 15, 2009
Loading...

Share This Page