Gossamer Forum
Home : General : Perl Programming :

delay java script

Quote Reply
delay java script
Hi!

I have modified a script I found on the Internet to the following one. Its purpose is to show an iframe tag 4 seconds after the html page has finished loading. However, the iframe tag always cover up all other materials when it loads. What is the problem with my script? Can anybody help me? By the way, can anybody see if there are any useless step in the script?

<script language="JavaScript">
<!--
timeFlag = 0;
blurFlag = 0;
popWinFlag = 0;
window.name="mainWin";
function initFocus() {
self.focus();
}
function waitForFocus() {
blurFlag=1;
}
function resetBlurFlag() {
blurFlag=0;
checkFlags();
}
function checkFlags() {
if (blurFlag == 0 && timeFlag == 1) {
createWin();
} else {
if (timeFlag == 1) {
waitForFocus();
}
}
}
function createWin() {
if (popWinFlag == 0) {
document.write('<iframe width="500" height="400"
frameborder="0" scrolling="no" marginheight="0px"
marginwidth="0px" src="http://www.yahoo.com"></iframe>');
popWinFlag = 1;
}
}
window.onload = initFocus;
window.setTimeout("timeFlag=1; checkFlags();",4000);
window.onblur = waitForFocus;
window.onfocus = resetBlurFlag;
// -->
</script>

Thanks a lot!

Quote Reply
Re: delay java script In reply to
You cannot document.write() into a static document after it has finished loading.

What you would have to do is include the IFRAME tag in the page but point it to a blank document, which refreshes to the desired content after 4 seconds.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: delay java script In reply to
Mmmm, be carful how you use IFRAMES though cos it doesn't work in certain browsers (e.g. most copies of Netscape). You need to make sure you use a compatable version of IFRAMES and LAYERS to accomidate both IE and Netscape Cool

Andy

http://www.ace-installer.com
webmaster@Ace-installer.com
Quote Reply
Re: delay java script In reply to
just use LWP and build a div. then in your js use setTimeout() for the delay and make the div visible.

-g


s/(\d{2})/chr($1)/ge + print if $_ = '8284703280698276687967';