I'm a bit stuck on this project (see below). It's part of a bigger project but I snipped the trouble piece out and put it in it's own little temporary page for now until I work out the kinks. What I need is a pop up window with "toy tips" or funny sayings to occur at certain timed intervals while the user is viewing the main page. For now I have the timed interval set to occur every 30 secs while I'm testing it.
Also, I need the pop up window to stay open for enough time for the user to read the "tip" then to close itself before the new tip pops up. For testing I have that time set to 10 secs.
Problem is, I can get the tip to pop up but it does not close and another tip does not show up.
Help, feedback and/or clues as to what I'm doing wrong would be greatly appreciated!
Thanks!
Tammy
<html>
<head>
<title>Toy Store Tips</title>
<script language="Javascript" type="text/javascript"><!--
var tips = new Array(8)
tips[0] = "Expand your child\'s creative thinking with our artistic themed toys!"
tips[1] = "Play Doh may NOT be eaten under any circumstances!"
tips[2] = "Do not place toys near heat sources."
tips[3] = "Jacks should not be used as projectiles!"
tips[4] = "Always wear protective gear when using bikes and skateboards!"
tips[5] = "Doll\'s hair may lose original color if put in water!"
tips[6] = "May the force be with you!"
tips[7] = "Do not let children under 3 play with small toys!"
function displayTip(tips, width, height){
var startDoc = "<html><head><title>Toy Tip</title></head>"
startDoc += "<body bgcolor=lime text=black>"
var endDoc = "</body></html>"
var xPos = screen.availWidth > width ? screen.availWidth/2 - width/2 : 0
var yPos = screen.availHeight>height ? screen.availHeight/2 - height/2: 0
var features = "width=" + width + ", height=" + height
features += ",screenX=" + xPos + ",screenY=" + yPos
toyTip = window.open("", "TipWin", features)
tipClose = setTimeout("toyTip.close()", 10000)
toyTip.document.writeln(startDoc, "<h2>Toy Tip</h2>")
toyTip.document.writeln(tips)
toyTip.document.writeln(endDoc)
}
//-->
</script>
</head>
<body onload="displayTip(tips[Math.floor(Math.random()*8)], 200, 150),">
<h2>Welcome to the Toy Store</h2>
<script language="Javascript" type="text/javascript"><!--
tipTimer = setInterval("displayTip(tips[Math.floor(Math.random()*8)], 200, 150)", "30000");
//-->
</body>
</html>

New Topic/Question
Reply



MultiQuote





|