Results 1 to 2 of 2

Thread: [RESOLVED] WebBrowser And JavaScript Confirmation

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    30

    Resolved [RESOLVED] WebBrowser And JavaScript Confirmation

    Hi All,

    I'm having problem handling javascript confirmation box (OK/Cancel).
    I already managed to click a button at runtime, but I need to bypass this confirmation box, or
    able to select ok.

    Here is the html of the script

    HTML Code:
    <input type="submit" name="btnpch" value="Purchace" onclick="return confirmation();" id="plchldr001" style="width:100px;" />
    Instead of calling the confirmation, I simply change the outerHtml to :

    HTML Code:
    <input type="submit" name="btnpch" value="Purchace" onclick="return true;" id="plchldr001" style="width:100px;" />
    When I click the button manually on the page, It will simply bypass the confirmation and proceed submitting the page. Its seems to be working well.

    But when I execute these code :


    Code:
                        
    Dim doc As HtmlDocument = WebBrowser1.Document
    Dim aC As HtmlElementCollection = doc.GetElementsByTagName("input")
    For Each he As HtmlElement In aC
            If he.GetAttribute("name") = "btnpch" Then
                 he.InvokeMember("onclick")
             End If
    Next
    It sill shows the confirmation. I noticed that When click manually on the button, it will skip the confirmation, but not if I click the button by code.

    What I do wrong here? Or any other solution to achieve this?

    I know a lot of posts out there already talking about this issues, but none seem to work for me.



    Thanx in advance...........

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2007
    Posts
    30

    Re: WebBrowser And JavaScript Confirmation

    After several hours, finally noticed that the documentcompleted raised several times and reset changes I make to the html code. So I just simply ensure the program wait till no more event raised and perform the click. I hope this will help others experiencing the same problem as I did.
    Last edited by muzaffarhabibi; Aug 21st, 2013 at 06:30 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width