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!

How to make Pop ups open and close in Sequence? 1

Status
Not open for further replies.

gabrielwert

Programmer
Jul 3, 2008
10
BR
Hi! What I have here below is a source code of an HTML page and some Javascript pop up in it. You can see a sample of this code on my website in the link below:


However as you see, the page loads and the pop-p apears and closes... but... what I want is sort of a list of links that the javascript will open after this pop up.. for example:

The pop up opens: var popwindowURL="What I want is a code for the page to continue opening more pop-ups but.. instead of opening var popwindowURL=" I want it to open other Urls in sequence, then open and close the same way as the first. I've been looking all over the web for help.. so far no one has a solution! can you help me? solution worth stars!

The source of: self_closing_alert_window-sample.htm


<html>
<head>
<title>Self-closing Alert Window</title>
<script>
<!-- Beginning of JavaScript -
var popwindow
var popwindowwidth=210
var popwindowheight=150
var popwindowtop=20
var popwindowURL="var waitingtime=10
var pause=20
var step=40
var popwindowleft=-popwindowwidth-50
var marginright
var pagecenter
var timer

waitingtime= waitingtime*1000

function showWindow() {
popwindow = window.open(popwindowURL, "popwindow", "toolbar=no,width="+popwindowwidth+",height="+popwindowheight+",top="+popwindowtop+",left="+(-popwindowwidth)+"");
if (document.all) {
marginright = screen.width+50
}
if (document.layers) {
marginright = screen.width+50
}
pagecenter=Math.floor(marginright/2)-Math.floor(popwindowwidth/2)
movewindow()
}

function movewindow() {
if (popwindowleft<=pagecenter) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow()",pause)
}
else {
clearTimeout(timer)
timer= setTimeout("movewindow2()",waitingtime)
}
}

function movewindow2() {
if (popwindowleft<=marginright) {
popwindow.moveTo(popwindowleft,popwindowtop)
popwindowleft+=step
timer= setTimeout("movewindow2()",pause)
}
else {
clearTimeout(timer)
popwindow.close()
}
}

// -->
</script>
</head>
<body onLoad="showWindow()">
When this page Loads, a pop up will apear and close in 10 seconds.
</body>

</html>
 
somthing like this?

Code:
<script language="javascript">
// urls to open
var strWindows = "[URL unfurl="true"]http://www.google.com,http://www.yahoo.com,http://www.ebay.com";[/URL]
// dump into an array
var raWindows = strWindows.split(",");
// counter
var i;
// each open window
var raMyWindow = Array();

function openWindows() {
	//open them
	for (i = 0 ; i < raWindows.length; i++) {
		raMyWindow[i] = window.open(raWindows[i],'window' + i,"toolbar=no");
	}
}

function closeWindows() {
	//close them
	for (i = 0 ; i < raWindows.length; i++) {
		raMyWindow[i].close()
	}
}
</script>

<a href="javascript:openWindows();">Open The Windows</a><br /><br />
<a href="javascript:closeWindows();">Close The Windows</a><br /><br />

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Yes! I think thats it.. i've tested it and from what I see, the values in the timer need to be inserted. Im a total begginer with Javascript. Could you help me or give me a more detailed explanation of how I can set the Pop-ups to open one by one but only after the first one closes in sequence. Google opens, stays open for 30 sec and then closes and then Yahoo Opens stays open for 30 sec then closes.. thats what I need. thank you for your help so far! ;D
 
do some research on the setTimeout() function in javascript...it basically executes a function after a specified period of time...

Using that + what I've given you should point you in the right direction. If you get stuck along the way, post what you've done so far and I'll take a look.



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top