469,272 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Passing an argument to window.open ?

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
May 11 '07 #1
5 8097
On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo...@nesto.hrwrote:
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)

May 11 '07 #2

"scripts.contact" <sc*************@gmail.comwrote in message
news:11*********************@e51g2000hsg.googlegro ups.com...
On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo...@nesto.hrwrote:
>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)
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
May 11 '07 #3
ASM
Nicholas a écrit :
>>
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

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

better with ' or " everywhere (not both)
better with no space
<button
onclick="nw(500,500);myWindow.document.write('hell o');">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 !

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
May 11 '07 #4
Lee
Nicholas said:
>

"scripts.contact" <sc*************@gmail.comwrote in message
news:11*********************@e51g2000hsg.googlegr oups.com...
>On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo...@nesto.hrwrote:
>>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)

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.
--

May 11 '07 #5
Nicholas wrote :
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">
It's <script type="text/javascript">

http://www.javascripttoolbox.com/bestpractices/#script
<!--
http://www.javascripttoolbox.com/bes...ices/#comments
function nw(a,b){
myWindow = window.open("", "Window", 'toolbar,width=a,height=b')
First, either just use double quote (") or single quote (') but not both.
//-->
http://www.javascripttoolbox.com/bes...ices/#comments
</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
Try

<script type="text/javascript">
var WindowObjectReference; // creating a global variable
function nw(a,b)
{
WindowObjectReference = window.open("", "SecondaryWindow",
"toolbar,width=" + a + ",height=" + b + "resizable,scrollbars");
}

You will find more useful, helpful info at:

DOM:window.open
http://developer.mozilla.org/en/docs/DOM:window.open

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
May 12 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

29 posts views Thread by wayne | last post: by
3 posts views Thread by Aaron | last post: by
2 posts views Thread by william.w.oneill | last post: by
5 posts views Thread by goldtech | last post: by
5 posts views Thread by kyosohma | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.