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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Same window twice

Status
Not open for further replies.

perlkid

Programmer
Mar 9, 2000
35
US

If I load an onload="popup();" in a body tag, I can get a popup window to show fine when the page loads, but when I refresh the page without closing the popup, it makes a new popup window instead of bringing up the old one again with the url. What can I do to use the same window?

Thanks,

Tony

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
Use a cookie to check whether the user already came and a window was opened for him.. if so, ignore the commands to open the pop up...


jared@aauser.com
 
I believe you can just do an if(){ condition to check for a child document, something like

Code:
if(!document.children['window_name']){
   window.open(etc....);
}

I'm not sure of the exact syntax, but this is the general idea.
 

Ok, Thanks Rycamor,

I'll try to do that.

Thanks Again.

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
I couldn't get that to work,

I'm not good with java script, but it's a lot like perl syntax so I usually do ok, could you help me out a little more.

This is what I have so far.

print qq~
<html>
<head>
<SCRIPT language=&quot;JavaScript&quot;>
<!--
function winscroll(URL, width, height) {
var now = new Date();
if(!window.child.popup){
var remote = window.open(URL, &quot;popup&quot; + now.getTime(), &quot;width=&quot; + width + &quot;,height=&quot; + height + &quot;,toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=0&quot;);
}
// if(navigator.appVersion.indexOf(&quot;MSIE 3&quot;) < 0)
// remote.focus();
}
defaultStatus = &quot;&quot;;

// -->
</SCRIPT>
</head>
<meta HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;20&quot;>
~;
#####
#End Javascript: - perl code
#####
if ($res[4] eq &quot;yes&quot;){
print qq~
<body onload=&quot;winscroll(' 620, 360);&quot;>
</body>
</html>
~;


It's a mix of perl and java, the perl generates the java, and you can see that it refreshes every 20 seconds. That's why if $res[4] my variable in perl , is == to something, it will write the body tag. That's why it pops a new window up every 20 seconds. My popup name is &quot;popup&quot;. Is there anything else you can think of?

Thanks A lot Mate,

Tony

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 

K I got it,

Thanks Anyway

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
Do you mind showing me the syntax you used? I was trying to check the documentation at developer.netscape.com and at msdn.microsoft.com/ie, but I wasn't getting anything useful.
 

Sure, I'm sure you already knew about this though

<SCRIPT language=&quot;JavaScript&quot;>
<!--
function winscroll(URL, width, height) {
var win = window.open(URL, &quot;popup&quot;,&quot;height=&quot; + height + &quot;,width=&quot; + width + &quot;,top=0,left=0,scrollbars,resizable&quot;);
win.moveTo(0, 0);
win.focus();
}
// -->
</SCRIPT>


What it does for me is, when a certain even happends with the perl, it will print the body tag with an onload=&quot;popup blabla&quot; so that it tells the user that something just happend. If you walk away from your computer, it will keep using the same window. If you minimize it then it re-opens it. I just randomly look for popup windows and I found that this one did it. I learned that it was all due to the win.focus(); to maximize the window every time it is relaunched and it's minimized. The reason it uses the same window is a mystery to me. Just does. The other one I was useing keeped opening new windows. So when i walked away from my computer it would be locked up when I got back, or just have like a 100 po-ups. he he.

I'd also like to kow how to have a link minimize a window. Like the <a href=&quot;javascript:window.close();&quot;>close window</a> does, but I need it to just minimize it. How can I do that?

Thanks For Digging Around For Me. That was nice of you.

Tony

Tony
tony@seeki.com
Experienced In: Perl, JavaScript, C++, PHP

Want More Experience In: Pascal, Python, PHP More C++
 
the reason is keeps using the same window is the fact that in your statement:

var win = window.open(URL, &quot;popup&quot;,&quot;options&quot;);
you always use the name &quot;popup&quot;. I have a feeling windows keeps track of the window using this second argument in the open method. trying keeping track of a count variable that you can increment every time you call the function and concat it to the end of the name (popup+i).


jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top