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.

Ignore Java script code in webbpage


I have been asked to admin a web site that offers on-line education in Financial Literacy. I am running a Beta with 74 mentors in the Chapel Hill School System. I have a script to auto-register the mentors, and to gather user statistics. After the Beta is over, I would like to remove all mentors. I do not have access to the db, but there is an 'unregister' link on each profile page.

My script navigates and clicks the link - but I get a pop-up screen (see attached). I have tried all combinations of SendKeysTo, child.. for example SendKeysTo("Microsoft", "~") - but nada.

Any suggestions?

Answer:

First we need to determine whether or not the window is a child window.

This code first of all makes a list of all parent windows, and allows you to choose one. Then it gets the list of all children of that parent for your perusal.


 parents=WinItemize()
 thisone=AskItemList("Choose a Parent Window",parents,@tab,@sorted,@single)
 children=WinItemChild(thisone)
 child=AskItemList("Children of %thisone%",children,@tab,@sorted,@single)

If its a parent window the code will probably look like this:
SendKeysTo("Microsoft Internet Explorer~","{ENTER}")
If its a child window the code will probably look like this:
SendKeysChild("~Microsoft Internet Explorer","Microsoft Internet Explorer~","{ENTER}")
Notice the use of tildes.

User Reply:

I've already tried all of the combinations you suggested. Here is my best guess at the issue:

In the script I issue

oIE.Document.Body.GetElementsByTagName("A").Item(6).Click()
which executes the Unregister Link, and pops-up the confirm dialog. However, at this point, the script is paused. I put in the code you suggested but it never executes until I manually address the pop-up dialog. I've also tried dropping my oIE Object, trying to set up oIE1 as a GetObject, and other why nots...

Answer:

In that case, I would launch a secondary WinBatch script right before the Click, then have the second script respond to the dialog.
Run("a.wbt","")
oIE.Document.Body.GetElementsByTagName("A").Item(6).Click()
a.wbt
title = "Microsoft Internet Explorer~"
If WinWaitExist(title, 10)then SendKeysTo(title,"{Tab}{ENTER}")
exit
Or try setting the onclick event to "", like this:

Winbatch Version: 2005C -- Script by Jay Alverson
;   seemed to be a timing issue...

;   anyway this seems to work and I get no CONFIRM and
;   no 2nd script...

#DefineSubRoutine startMSIE(url)
   Browser = ObjectOpen("InternetExplorer.Application")
   Browser.addressbar = @FALSE
   Browser.statusbar = @FALSE
   Browser.menubar = @FALSE
   Browser.toolbar = @FALSE
   browser.visible = @TRUE
   browser.navigate(url)
   ; wait until page loads...
   While Browser.busy || Browser.readystate <> 4
      TimeDelay(0.5)
   EndWhile
   ; setup the document object...
   browserDoc = Browser.Document
   all = browserdoc.all
   Return(browser)
#EndSubRoutine

#DefineSubRoutine WaitForBrowser()
   While Browser.busy || Browser.readystate <> 4
      TimeDelay(0.5)
   EndWhile
   Return
#EndSubRoutine

url = "www.money-4-living.com"

br = startMSIE(url)

browser.document.GetElementsByTagName("A").item(2).click
WaitForBrowser()

browser.document.GetElementsByTagName("A").item(6).onclick = ""
browser.document.GetElementsByTagName("A").item(6).click
WaitForBrowser()

Exit

User Reply:

The secondard script the send keys to the dialog works just fine.

I also tested the onclick="" to the script and jsmith was history. I didn't realize you could ignore Jscript code like that - thanx again


Article ID:   W17179
File Created: 2007:07:03:14:28:36
Last Updated: 2007:07:03:14:28:36