Jump to content

(Solved)Handle DWebBrowserEvents2 (javascript)


Recommended Posts

EDIT: I was looking at this arse ways about, and did not need any EventScript Inserted.

I'm trying to analyze a url before I navigate to it and if necessary cancel the navigation.

I'm looking at BeforeNavigate2 event, which I can capture successfully using ObjEvent().

But I would like to insert code into the page to deal with that event.

I'm having no luck, and there are no working examples of this on the forum.

Here is my latest minimalistic code.

#include <IE.au3>

$oIE = _IECreate("http://www.google.com")

_IEHeadInsertEventScript($oIE, "document", "BeforeNavigate2", "cancel;") ; No go - tried "return false;"

ObjEvent($oIE, "_Evt_","DWebBrowserEvents2")

While 1
Sleep(100)
WEnd

Func _Evt_BeforeNavigate2($IEpDisp, $IEURL)
Local $o_link = @COM_EventObj
MsgBox(0, 0, $IEURL) ; occurs
EndFunc ;==>_Evt_BeforeNavigate2

The MsgBox shows with the url , but navigation still occurs.

Anyone successfully done this sort of thing?

EDIT:

I have tried example 5 in help file for _IEHeadInsertEventScript() but it does not work on all links, perhaps because of frames, or some other such html wizardry.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Shameless Bump, can't find any info on this anywhere :D

EDIT:

Is there anyway I could trigger/fire a NavigateComplete2 event, and fool the WebBrowser object into thinking

it has completed it's navigation?

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...