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

Passing a variable into a function

Status
Not open for further replies.

solomania9

Technical User
Sep 23, 2001
7
US
Hi All,

The answer to my question is probably quite simple, but here goes...

I want to launch different windows with different widths and heights but USING THE SAME FUNCTION in the head of the document. Here's what I have so far...

Inside the <head>:

function newWindow(url, newWidth, newHeight) {
voteWindow = window.open(url, 'title', 'scrollbars=no,width=492,height=newHeight')
}

and on the link:

<a href=&quot;javascript:newWindow('agfa.html', '200', '200')&quot;

Let me know why it's not working. Thanks! :)

~Mike
 
I would change your function to :

function newWindow(url, newWidth, newHeight){
window.open (........BLAAAHHH.....);
}

Get rid to the var encompassing the window.open fxn.
The reason it's not working for you is becuase the (features) part of the arguments, or 3rd arg, for the new Window is a STRING. In order for you to be able to encompass your values into the string it needs to be broken up like so:

var featuresList = &quot;scrollbars=no,width=&quot; + newWidth + &quot;,height=&quot; + newHeight;

Now just type in featuresList as the third argument to the window.open fxn. Rocco is the BOY!!

M O T I V A T E!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top