PDA

View Full Version : Pop-up window - bring to the front


robsta
08-18-2003, 10:37 PM
Hi there!

When a user exits a pop-up window on my site and returns to the main page, the pop-up takes its place behind the main window.

Is there a way to alter my existing pop-up script so that the pop-up will move forward when the originating link on the main page is clicked?

code:
<a href="#" class="paper" onClick="window.open('../popups/uno. html','MyWindow2','toolbar=no,location=no,
directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=400,height=515,left=5px,top=5p x');return false;">
<img alt="Paper" src="../images/TetonUno.jpg" height="89" width="88" border="0"></a>

Thanks - all suggestions appreciated.

Robsta
:)

Vincent Puglia
08-18-2003, 11:23 PM
Hi robsta,

name the window and then set focus:

var newWin = window.open(....)
newWin.focus();

Vinny

Mr J
08-18-2003, 11:25 PM
You could put this is the popup file




<SCRIPT LANGUAGE="JavaScript">
function test() {
setTimeout("self.focus()",3000)
}
</script>


<BODY onblur="test()">


Adjust the timeout to suit

robsta
08-19-2003, 12:10 AM
name the window and then set focus:

var newWin = window.open(....)
newWin.focus();

Hi Vinny -

Thanks for the code.

How would I add this to my existing script? Would you mind pasting it into my code example above?

Robsta
:confused:

robsta
08-19-2003, 12:19 AM
<SCRIPT LANGUAGE="JavaScript">
function test() {
setTimeout("self.focus()",3000)
}
</script>


<BODY onblur="test()">


Adjust the timeout to suit


Hi and thanks for the code Jeff -

I already have an onLoad event happening in the <body> of the pop-up - will they be compatible?

Code:
<!-- Begin
function loadImages() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hidepage.visibility = 'hidden';
}
else { // IE 4
document.all.hidepage.style.visibility = 'hidden';
}
}
}
// End -->

<body OnLoad="loadImages() ">

Look forward to your reply.
Robsta

MotherNatrsSon
08-19-2003, 12:31 AM
I thin it would look something like this

<body OnLoad="loadImages()"; onblur="test()">

I also believe there will be no conflict.

MNS

robsta
08-19-2003, 12:36 AM
Hey there -

Looks good to me - I didn't know if there'd be a conflict. Thanks for the code.

Robsta
:thumbsup:

robsta
08-19-2003, 03:01 AM
Hi guys -

The good news - the script works.
The bad news - I have more than one link to the popup on the mainpage, so the popup's coming fwd each time I scroll the page. Is there any other event handler that we could substitute to give the user more control over the how often the window pops back up?

Thanks -
Robsta
:)

robsta
08-19-2003, 03:34 AM
Thanks! Script works great. Sent you a PM to get your okay on my syntax - it worked, but is it kosher?

Robsta
:)

Vincent Puglia
08-19-2003, 02:20 PM
Hi robsta,

read your pm's -- thought it would be better to answer here.

Rule of thumb: if the code is longer than your thumb, don't put it within the HTML; create a function.
The one below is meant to be taken as an example, more than anything else. If you have more than one link on the page, you can modify it by: sending a parameter -- the link's id, perhaps (<a href="#" id='a'...onclick='openIt(this.id)' -- and then using a switch or series of if/else statements to either build the window.open text (preferred method) or execute the window.open.


[code]
<script type="text/javascript">
<!--
var myWin;
function openIt()
{
myWin = window.open('../popups/uno.html', 'MyWindow2', "toolbar='no', location = 'no', directories = 'no', status = 'no', menubar = 'no', scrollbars='no', resizable='yes', width = 400, height=515, left='5px', top='5px'");
myWin.focus()
}
//-->
</script>
</head>
<body>
<a href="#" class="paper" onClick="openIt()"><img alt="Paper" src="../images/TetonUno.jpg" height="89" width="88" border="0"></a>

</body>
[\code]

Vinny

robsta
08-19-2003, 10:11 PM
Hey Vinny!

Thanks for the script fix and the mini-tutorial. I'll follow your rule of thumb and proceed from there...

Grazie!
Robsta
:)