AzzerShaw
(Seasoned Scripter)
2004-11-23 05:01 PM
Can i get this to refresh? web page refresh

Dear,

Im having problems getting this to refresh the same IE page . I am uselss at html scripting and this is my first try so excuse me and no mickey taking.

Code i got so far

Code:
  

Break on
SetConsole("hide")

Open (1,"c:\temp\sw_audit.txt")



$Splash = Splash("C:\temp\cbs.jpg")
Sleep 8
$Splash.Quit()
$Splash = 0
;Exit

Do
$CompName=ReadLine(1)


Function Splash($picture)
Dim $ie
$ie = CreateObject("internetexplorer.application")
$ie.fullscreen = 0
$ie.menubar = 1
$ie.statusbar = 0
$ie.toolbar = 0
$ie.width = 500
$ie.height = 500
$ie.navigate("about:blank")
While $ie.busy AND $ie.readystate <> 4 AND @error = 0 Loop


$Aaron=$Aaron+1
$html="


<HTML>

<HEAD>

<TITLE>Working With VBScript: Exercise 1</TITLE>

</HEAD>

<BODY>

<H1>Your First Html Exercise</H1>

<P> By utilizing $Aaron you can give your Web pages actions.

Click on the button below to see what we mean. </P>

</SCRIPT>

</FORM>

</BODY>

</HTML>

"
$ie.document.write($html)
$ie.visible = 1
$Splash = $ie
EndFunction


Until $CompName = ""





It basically just counting every time it reads a line and i need this being put into the web page


Thanks all

Aaron


Richard H.Administrator
(KiX Supporter)
2004-11-23 05:05 PM
Re: Can i get this to refresh? web page refresh

There are a number of ways to do this.

Simplest is to create a form with a field on it, and update the field value.

You can also create discrete sections (using DIV), or even name areas between FONT sections and update them.

Updating using .write is pretty ugly and should be avoided.

ISTR I posted a countdown example on the board just recently. Hang on while I have a decko...


Richard H.Administrator
(KiX Supporter)
2004-11-23 05:08 PM
Re: Can i get this to refresh? web page refresh

Ok, this example updates the HTML on the page.

Forms and named sections are the way to go though. You can do some great tricks.


Richard H.Administrator
(KiX Supporter)
2004-11-23 05:23 PM
Re: Can i get this to refresh? web page refresh

Here is a similar example to the one posted above.

In this version I use DIV to demarcate the area that I want to update. I give the area a name, and then use ".getelementbyid()" to get the area as an object.

You will see that the simple text on the page is unaffected while the rest of it changes. You can use this technique to label discrete areas of the page that you wish to update.

Code:
$oIE=funMakeIE("Countdown timer demo",150,400)


$oIE.document.body.innerHTML="<CENTER>Dynamic area below<DIV ID=divUpdate></DIV></CENTER>"
$oDIV=$oIE.document.getelementbyid("divUpdate")
For $i = 10 To 0 Step -1
Select
Case $i<3 $COLOUR="RED"
Case $i<6 $COLOUR="YELLOW"
Case "Default" $COLOUR="GREEN"
EndSelect
$oDIV.innerHTML="<CENTER><FONT COLOR="+$COLOUR+" SIZE=7>Countdown: "+$i+"</FONT></CENTER>"
Sleep 0.5
Next
$oDIV.innerHTML="<CENTER><FONT COLOR=RED SIZE=7><B>**BOOM**</B></FONT></CENTER>"
Sleep 3

$oIE.Quit
$oIE=0
Exit 0

; -------------------------------------------------------
; Ignore everything below here - this is black-box magic.
; -------------------------------------------------------
Function funMakeIE($sTitle,$iHeight,$iWidth)
$funMakeIE=CreateObject("InternetExplorer.Application")
If $funMakeIE
; Remove clutter
$funMakeIE.toolbar=0 $funMakeIE.menubar=0 $funMakeIE.addressbar=0 $funMakeIE.statusbar=0
; Load dummy
$funMakeIE.navigate("about:blank")
funWait($funMakeIE)
Else
funError("Cannot create IE object")
Exit 1406
EndIf

$funMakeIE.document.write("<HTML>
<HEAD>
<!--
Hand crafted script
Created R. Howarth March 2004
-->
<TITLE>"+$sTitle+"</TITLE>
<SCRIPT Language=JavaScript>
function funDispatcher(s){
frmMain.sStatus.value+=s+';';
}
function funGetScreenSize(){
frmMain.screenheight.value=screen.availHeight;
frmMain.screenwidth.value=screen.availWidth;
}
</SCRIPT>
</HEAD>
<BODY onLoad='funGetScreenSize();' BGCOLOR=LIGHTGREY>
<FORM Name=frmMain>
<INPUT Type=Hidden Name=screenheight Value=''>
<INPUT Type=Hidden Name=screenwidth Value=''>
</FORM>
</BODY>
</HTML>")

$funMakeIE.refresh()
funWait($funMakeIE)
$funMakeIE.height=$iHeight
$funMakeIE.width=$iWidth
$funMakeIE.left=(Cint($funMakeIE.document.frmMain.screenwidth.value)-$iWidth)/2
$funMakeIE.Top=(Cint($funMakeIE.document.frmMain.screenheight.value)-$iHeight)/2
$funMakeIE.visible=1
funWait($funMakeIE)
$=SetFocus($TITLE)
$funMakeIE.visible = 1

Exit 0
EndFunction

Function funWait($oIE)
While $oIE.busy AND $oIE.readystate <> 4 AND @error = 0 Loop
Exit @ERROR
EndFunction



AzzerShaw
(Seasoned Scripter)
2004-11-23 05:31 PM
Re: Can i get this to refresh? web page refresh

Thats the one, thats great. I tried to find it earlier but couldnt find it.

I cant see how to make it count though, am i on the right track?

Code:
 
Break on

While @ERROR = 0

$Aaron=$aaron+1


$oIE=funMakeIE("Countdown timer demo",500,500)


$oIE.document.body.innerHTML="<CENTER> "$aaron" </CENTER>"
Sleep 0.5
$oIE.Quit
$oIE=0
Exit 0

Loop







Richard H.Administrator
(KiX Supporter)
2004-11-23 05:40 PM
Re: Can i get this to refresh? web page refresh

This would be better:
Code:
Break on
$oIE=funMakeIE("Countdown timer demo",500,500)
$oIE.document.body.innerHTML="<CENTER>MY COUNTER HERE: <FONT ID=divAARON></FONT></CENTER>"
$oDIV=$oIE.document.getelementbyid("divAARON")

$iAARON=0
While @ERROR = 0
$iAARON=$iAARON+1
$oDIV.innerHTML=$iAARON
If Not @ERROR Sleep 0.5 EndIf
Loop

$oIE.Quit
$oIE=0
Exit 0



AzzerShaw
(Seasoned Scripter)
2004-11-23 05:46 PM
Re: Can i get this to refresh? web page refresh

Thats great Rich, your a star!!!

Do you know why the web page opens up right in the corner of my screen, im scanning through and have changed the

$oIE=funMakeIE("Countdown timer demo",500,500)

But this doesnt seem to make a differnece


AzzerShaw
(Seasoned Scripter)
2004-11-23 06:03 PM
Re: Can i get this to refresh? web page refresh

I have found it HOORAH!!



AzzerShaw
(Seasoned Scripter)
2004-11-26 11:45 AM
Re: Can i get this to refresh? web page refresh

Is there a way that I can make this web page dedicated to the refresh? At the moment if i launch a web address it opens up in this box. Is there a way round this?

Richard H.Administrator
(KiX Supporter)
2004-11-26 12:23 PM
Re: Can i get this to refresh? web page refresh

Tricky.

If you can live with it the simplest method is probably to change the "Reuse windows for launcing shortcuts" option in your IE options setting.


AzzerShaw
(Seasoned Scripter)
2004-11-26 12:27 PM
Re: Can i get this to refresh? web page refresh

Thanks Rich. IE is locked down in the policy and changing the settings would involve three months of testing documenteting.....doh!!!

Thanks anyway