Results 1 to 15 of 15

Thread: [RESOLVED] Help With Kleinma's Suppressing Javascript Alerts in WebBrowser

Hybrid View

  1. #1
    Member VBobCat's Avatar
    Join Date
    Sep 2011
    Location
    São Paulo, Brazil
    Posts
    34

    Re: [RESOLVED] Help With Kleinma's Suppressing Javascript Alerts in WebBrowser

    I'd like to share an interesting result of some simple modifications to Kleinma's brilliant original. This is what I did:
    1) I increased tmrPopCheck.Interval from 100 to 1000;
    2) I suppressed the line "tmrPopCheck.Stop()" at the Sub "tmrPopCheck_Tick";
    3) I replaced the line "If (PopupHandle <> IntPtr.Zero) AndAlso (PopupHandle <> WB.Handle) Then" by "If (PopupHandle <> IntPtr.Zero) AndAlso (PopupHandle <> WB.Handle) AndAlso (PopupHandle <> Me.Handle) Then".
    By doing this, every JSAlert (both "onload" and "onclick") is now promptly killed, and the form is not closed.

    I have also a question:
    What if my page has a JS Confirm pop-up (with OK and Cancel buttons) instead of a simple Alert? How could I give it one or other of these answers programatically? Is that possible?
    Thank you very much!

  2. #2
    Member VBobCat's Avatar
    Join Date
    Sep 2011
    Location
    São Paulo, Brazil
    Posts
    34

    Re: [RESOLVED] Help With Kleinma's Suppressing Javascript Alerts in WebBrowser

    Ok, it's possible to select JS-Confirm response by replacing line "PostMessage(PopupHandle, &H10, New IntPtr(1), IntPtr.Zero)" with one of these:
    -> "PostMessage(PopupHandle, &H100, New IntPtr(13), IntPtr.Zero)" (posts "Enter" typing, i.e. Ok)
    -> "PostMessage(PopupHandle, &H100, New IntPtr(27), IntPtr.Zero)" (posts "Esc" typing, i.e. Cancel)
    VBobCat
    VS2013 & Office-VBA
    Autodidact, part-time programmer for job needs

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