cloop Posted March 18, 2007 Share Posted March 18, 2007 How might I obtain a target URL before navigating to it. I have tried using the BeforeNavigate and although I'm catching the event I'm unclear on where the target URL is stored. Thanks in advance, Cloop. Link to comment Share on other sites More sharing options...
DaleHohm Posted March 18, 2007 Share Posted March 18, 2007 This help? $oLinks = _IELinkGetCollection ($oIE) ConsoleWrite("Number of links found: " & @extended & @CR) $i = 0 For $oLink in $oLinks ConsoleWrite($i & ": " & $oLink.href & ", Target: " & $oLink.target & @CR) $i += 1 Next Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
cloop Posted March 18, 2007 Author Share Posted March 18, 2007 This help? $oLinks = _IELinkGetCollection ($oIE) ConsoleWrite("Number of links found: " & @extended & @CR) $i = 0 For $oLink in $oLinks ConsoleWrite($i & ": " & $oLink.href & ", Target: " & $oLink.target & @CR) $i += 1 Next Dale I should have been clearer - I was thinking more of a click from favourite/bookmark or text typed into the address bar. Surely the URL would be stored somewhere allowing it to be intercepted prior to page-loading. Thanks for the information so far, though. Cloop Link to comment Share on other sites More sharing options...
Hasher Posted March 18, 2007 Share Posted March 18, 2007 You could use the BeforeNavigate2 () event in IE to tell when you start moving away from a page then check the IE address bar for the offending urls that you dont want. Below is some code that should start you on your wayhttp://msdn.microsoft.com/library/default....renavigate2.asp$oDWEvents = ObjEvent ($oIE, "DWEvent_", "DWebBrowserEvents2") Func DWEvent_BeforeNavigate2() $url = _IEPropertyGet ($oIE, "locationurl") EndFunc Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
cloop Posted March 18, 2007 Author Share Posted March 18, 2007 You could use the BeforeNavigate2 () event in IE to tell when you start moving away from a page then check the IE address bar for the offending urls that you dont want. Below is some code that should start you on your way http://msdn.microsoft.com/library/default....renavigate2.asp $oDWEvents = ObjEvent ($oIE, "DWEvent_", "DWebBrowserEvents2") Func DWEvent_BeforeNavigate2() $url = _IEPropertyGet ($oIE, "locationurl") EndFunc The code above this post is the code I've been using - it doesn' t work and grabbing the address from the bar only works if there is an address- bar to grab from. Again, thanks for the hep so far. Cloop Link to comment Share on other sites More sharing options...
Hasher Posted March 18, 2007 Share Posted March 18, 2007 In _BeforeNavigate2 the second param is 'ByRef Url As Variant' which would be much or reliable than getting from the address bar :-D Private Sub object_BeforeNavigate2( _ ByVal pDisp As Object, _ ByRef Url As Variant, _ ByRef Flags As Variant, _ ByRef TargetFrameName As Variant, _ ByRef PostData As Variant, _ ByRef Headers As Variant, _ ByRef Cancel As Boolean) Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
DaleHohm Posted March 19, 2007 Share Posted March 19, 2007 Your idea is sound, but the com event processing in AutoIt is handled asynchronously and will not give you the opportunity to affect their outcome in most cases. Please see a discussion of it here.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
cloop Posted March 19, 2007 Author Share Posted March 19, 2007 I take then, that this means there is no way to grab the target URL using the DOM. Cheers anyway. Cloop Link to comment Share on other sites More sharing options...
DaleHohm Posted March 19, 2007 Share Posted March 19, 2007 I take then, that this means there is no way to grab the target URL using the DOM.Cheers anyway. CloopYou can, but you can't cancel a navigation because because of the asynchronous nature of the event processing. You can still get the URL as one of the parameters sent to onBeforeNavigate2 as Hasher points out.If you want to be able to examine and cancel navigation events you'll need to inject client-side javascript -- it really isn't hard to do with _IEDocInsert*Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
cloop Posted March 19, 2007 Author Share Posted March 19, 2007 You can, but you can't cancel a navigation because because of the asynchronous nature of the event processing. You can still get the URL as one of the parameters sent to onBeforeNavigate2 as Hasher points out.If you want to be able to examine and cancel navigation events you'll need to inject client-side javascript -- it really isn't hard to do with _IEDocInsert*DaleThanks all, for your time and interest.Regards, Cloop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now