Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE7 - Cannot do window.location with about:blank... 1

Status
Not open for further replies.

stephenmbell

IS-IT--Management
Jan 7, 2004
109
US
I have a script that simulates a progress bar by using IE. This script works fine on IE6, but does not work on IE7 - it doesnt seem to like the document.window.location = "about:blank" (I am looking to basically clear out any text that is in the browser)

here is the script.. thank in advance for any information.

Code:
Option Explicit

Dim objIE, n
Dim objFSO, fileFound

Set objFSO = CreateObject("Scripting.FileSystemObject")


If objFSO.FileExists("C:\dwh\progressbar.txt") Then
	fileFound = True
Else
	fileFound = False
End If

Set objIE = CreateObject("internetexplorer.application")
'Here is a phony progress bar that uses an IE Window

'in code, the colon acts as a line feed
With objIE
  .navigate2 "about:blank" 
  .width = 350 
  .height = 100 
  .toolbar = false 
  .menubar = false 
  .statusbar = false 
  .visible = True  
End With


objIE.document.write "<font face=" & Chr(34) & "Arial" & Chr(34) &"><b>Preparing Data..</b><br>"
objIE.document.write "<font color=blue>"

Do While fileFound = True
  
  For n = 1 to 100
    If objFSO.FileExists("C:\dwh\progressbar.txt") Then
	    fileFound = True
      objIE.document.write "|"
      wscript.sleep 50
      objIE.document.title = "Preparing Data..."	    
    Else
	    fileFound = False
	    objIE.document.location = "about:blank"
	    objIE.document.write "<font face=" & Chr(34) & "Arial" & Chr(34) & "><b>Data Loaded!</b><br>"
	    Exit For
    End If  

  Next
  objIE.document.location = "about:blank"
  If objFSO.FileExists("C:\dwh\progressbar.txt") Then
	  fileFound = True
  Else
	  fileFound = False
  End If
  
  If fileFound = True Then
    objIE.document.location = "about:blank"
    objIE.document.write "<font face=" & Chr(34) & "Arial" & Chr(34) &"><b>Preparing Data..</b><br>"
    objIE.document.write "<font color=blue>"
  End If
Loop

objIE.quit

set objIE = nothing
 
I'm using WinXP SP2 and IE7 and your code worked fine on my laptop.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
hmmm

the problem i am having is, the machines with IE 6 go like this...


|||||||| (100 |'s, then clear the browser and start fresh)

the IE 7 machines do 100 |'s then scroll to the next line, almost like a <br>

 
There are a couple of things in the script you might tighten up to vest more rigor maybe ie7 would be more ready to take.
[1] When you change location, navigate or re-assign location, you have to leave the engine to work through until readystate=4. In fact, repeatedly re-locate the page to "about:blank" is unnecessary. (see the revision)
[2] When you finish writing to the document, close it before any other action. (This can be quite unpredictable...)
[3] It looks too many fileexists() checking. It confuses the logic and is unnecessary. (see the revision)

Try this revision see if it works on ie7.
[tt]
Option Explicit
Dim objIE, n
Dim objFSO, fileFound, fpath

fpath="C:\dwh\progressbar.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
filefound=objFSO.FileExists(fpath)

Set objIE = CreateObject("internetexplorer.application")
'Here is a phony progress bar that uses an IE Window

'in code, the colon acts as a line feed
With objIE
.navigate2 "about:blank"
do while .readystate<>4 : wscript.sleep 50 : loop
.width = 350
.height = 100
.toolbar = false
.menubar = false
.statusbar = false
.visible = True
End With

Do While fileFound = True
objIE.document.open
objIE.document.write "<html><head><title>Preparing Data...</title></head><body>"
objIE.document.write "<font face=" & Chr(34) & "Arial" & Chr(34) &"><b>Preparing Data..</b></font><br />"
objIE.document.write "<font color=""blue"">"

For n = 1 to 100
If objFSO.FileExists(fpath) Then
fileFound = True
objIE.document.write "|"
wscript.sleep 50
Else
fileFound = False
Exit For
End If
Next

objIE.document.write "</font></body></html>"
objIE.document.close

if not fileFound then
objIE.document.open
objIE.document.write "<html><head><title>Preparing Data...</title></head><body>"
objIE.document.write "<font face=" & Chr(34) & "Arial" & Chr(34) & "><b>Data Loaded!</b></font>"
objIE.document.write "</body></html>"
objIE.document.close
end if
Loop

objIE.quit
set objIE = nothing
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top