Passing an argument to window.open ?

N

Nicholas

Hello, i need to pass an argument to window.open but it seems it wont work.
What am i doing wrong?

This in in head:

<SCRIPT LANGUAGE="JavaScript">
<!--
function nw(a,b){
myWindow = window.open("", "Window", 'toolbar,width=a,height=b')
//-->
</SCRIPT>

and this is in body:

<input type="button" value="open new window" onClick="nw(500,500)">

The problem is it opens the window but not 500x500 or any other dimension i
put
 
S

scripts.contact

Hello, i need to pass an argument to window.open but it seems it wont work.
What am i doing wrong?

This in in head:

<SCRIPT LANGUAGE="JavaScript">
<!--
function nw(a,b){
myWindow = window.open("", "Window", 'toolbar,width=a,height=b')
//-->
</SCRIPT>
<input type="button" value="open new window" onClick="nw(500,500)">

The problem is it opens the window but not 500x500 or any other dimension i
put

myWindow=window.open("", "Window", 'toolbar,width='+a+',height='+b)
 
N

Nicholas

scripts.contact said:
myWindow=window.open("", "Window", 'toolbar,width='+a+',height='+b)

This wont work. So as i see when i want to pass an argument i should use
'+a+' and '+b+' instead of yut a and b
 
A

ASM

Nicholas a écrit :
This wont work. So as i see when i want to pass an argument i should use
'+a+' and '+b+' instead of yut a and b


myWindow = window.open('','myWindow','toolbar=1,width='+a+',height='+b);

better with ' or " everywhere (not both)
better with no space


<button
onclick="nw(500,500);myWindow.document.write('hello');">hello</button>


could not work with IE6 or 7 because of (bad ?) security or preferences
fixed on "No popup"
could not work on FF because of anti-popup or preferences fixed on "No
popup"
and so on ... : popup is bad !
 
L

Lee

Nicholas said:
This wont work. So as i see when i want to pass an argument i should use
'+a+' and '+b+' instead of yut a and b

For readability, the first person singular pronoun "I" is capitalized.

You need to find a tutorial to read until you understand what a
string literal is. 'toolbar,width=a,height=b' is a string literal
and so variable names within it are not dereferenced.


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,104
Latest member
LesliVqm09
Top