Forum Moderators: open

Message Too Old, No Replies

Passing arguments to a script that opens a new window

How do I pass window dimensions as arguments?

         

doctormelodious

1:02 am on Jun 15, 2004 (gmt 0)

10+ Year Member



Greetings,

I found this script online:

<!-- Begin
function Start(thePage,theName) {
OpenWin = this.open(thePage, theName, "toolbar=no,menubar=no,location=no,scrollbars=yes,
resizable=yes,width=300,height=500");
}
// -->

I can pass the URL in the variable "thePage" and the name of the window in "theName." My question is, how can I pass the width and the height, since they appear as part of a string in quotes? I tried this:

<!-- Begin
function Start(thePage,theName,theWidth,theHeight) {
OpenWin = this.open(thePage, theName, "toolbar=no,menubar=no,location=no,scrollbars=yes,
resizable=yes,width=theWidth,height=theHeight");
}
// -->

but it just opened in a full-size window (by default, I guess). I have a single page with buttons that open several different temporary child windows, and it seems silly to have to have a separate script for each one, with the dimensions hard-wired in.

Of course, I could just spell out the whole "OpenWin =..." command for each button. But it would be nice to keep it as a script in the HEAD element.

Thanks for any suggestions!

Perry

tedster

3:18 am on Jun 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, Perry. This is really a javascript question, not just html.

Check out our generic javascript thread [webmasterworld.com], message #4 with the title "CUSTOM SIZE POPUP WINDOWS" - I think that does exactly what you're asking about. And if you need more help with this, our Javascript Forum is a great place to get it.