WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

BeforeNavigate2 Example


Question:

I want to present an imagemap of North Carolina in a WB dialog. Each county is sectioned as in
< area href="#counties" alt="Currituck" coords="605,3,605,3,630,2,646,52,629,38,605,7" shape="polygon" >
Normally the href would open another page, but I just want to keep the map displayed and instead find a way to turn control back to WB when a county is clicked so that statistics can be shown for that county in a pop-up spreadsheet. I was hoping maybe an onclick() event could be assigned with ObjectEventAdd() and passed the alt= as a lookup, but I can't come up with one. Anyone have alternatives?

Answer:

Maybe try the BeforeNavigate2 event.
; Winbatch Version: 2006C -- Script by Jay Alverson
#DefineFunction startMSIE(url)
   msie = ObjectCreate("InternetExplorer.Application")
   msie.addressbar = @FALSE
   msie.statusbar = @FALSE
   msie.menubar = @FALSE
   msie.toolbar = @FALSE
   msie.visible = @TRUE
   msie.navigate(url)
   WaitForMSIE(msie)
   Return(msie)
#EndFunction

#DefineFunction WaitForMSIE(msie)
   While msie.busy || msie.readystate <> 4
      TimeDelay(0.5)
   EndWhile
   Return
#EndFunction

;Event BeforeNavigate2(pDisp As Object, URL, Flags, TargetFrameName, PostData, Headers, Cancel As Boolean)
;    Member of SHDocVw.InternetExplorer
;    Fired before navigate occurs in the given WebBrowser (window or frameset element). The processing of this navigation may be modified.

#DefineSubRoutine BN(one,TargetURL,three,four,five,six,CancelNavigation)

;   just check the activeElement to see if an AREA tag was clicked...

   Message(br.document.activeElement.tagName, TargetURL)
   CancelNavigation = @TRUE ;cancel the navigation...
   loop = @FALSE
   Return
#EndSubRoutine

#DefineSubRoutine NewWindow(one, CancelArg)
   CancelArg = @FALSE
   a1 = ObjectTypeGet(one)
   a2 = ObjectTypeGet(CancelArg)
   Message(a1, a2)
   loop = @FALSE
   Return
#EndSubRoutine

url = "http://www.google.com/search?hl=en&q=winbatch"
br  = startMSIE(url)

daBrowser = br
ObjectEventAdd(daBrowser, "BeforeNavigate2", "BN")

loop = @TRUE
While loop
   TimeDelay(0.5)
   Yields(200)
EndWhile

Exit

User Reply:

To get the ALT tag I just used:
oIE.document.activeElement.alt
which returns the 'clicked' county, which goes into an SQL query.
Article ID:   W17168
File Created: 2007:07:03:14:28:34
Last Updated: 2007:07:03:14:28:34