Computing.Net > Forums > Web Development > More on javascript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

More on javascript

Reply to Message Icon

Name: Jamie_McCoy
Date: April 11, 2005 at 02:13:47 Pacific
OS: XP Pro 5.1
CPU/Ram: Pentium 4 2.4Ghz
Comment:

ok, i got a popup script, listed below

function profile_window(wname)
{
newWindow=window.open('','test','menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width=557,height=389');
newWindow.location=wname;
}

now, ive got the above code 4 times, but with different hight and width for use with 4 different pages on my site.. works great, 1 problem tho...

if someone has clicked and launched a popup, if they launch another 1 while that popup is still open, the new page will load in the existing popup.... bad!

so, just as a test, tried another popup code

function enterchat_window(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=784,height=500,left = 484.5,top = 356.5');");
}

now... when that is called, it opens in a new window than the other popup code 1, but, again, if u call another popup usin the same code, it just loads in the popup thats already 'poped up'

am i missing somethin?

roamhosting.net



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: April 11, 2005 at 13:48:42 Pacific
Reply:

Uh, yeah. In your first example replace 'test' with the variable wname that is being passed to the function. Then remove the second line "newWindow.location=wname"

Every time you call the function, it is opening a window called 'test'. Of course if that window already exists (which it does after the first time) it just opens the contents in the current instance.

If it were me, I'd also pass the URL to the function as well as the height and width since yousay those vary. Something like this:

function newWindow(wname,url,width,height) {

wname=window.open(url,wname,'menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width='+width+',height='+height);

}

The one problem with this is that if you try to open a new window with the same name as one that already exists, the windows will not be resized - it will just load the new contnet. You could either do a check to see if a window of the same name is open (and close it if it is) or resize the window after opeining the page. But, from what you explained, this should work for you.

Michael J


0

Response Number 2
Name: Jamie_McCoy
Date: April 11, 2005 at 16:37:08 Pacific
Reply:

perfect !!

roamhosting.net


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: More on javascript

JavaScript change style on events www.computing.net/answers/webdevel/javascript-change-style-on-events/2619.html

javascript menu www.computing.net/answers/webdevel/javascript-menu/1696.html

Do my webpage contain viruses? www.computing.net/answers/webdevel/do-my-webpage-contain-viruses/1825.html