|
|
 |
 |
 |
 |
Javascript / Client Side Development
|
 |
 |
 |
 |
 |
 |
 |
 |
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
On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo@nesto.hr> 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"> > <!-- > 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)
"scripts.contact" <scripts.cont @gmail.com> wrote in message news:1178881669.842400.51010@e51g2000hsg.googlegroups.com...
> On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo @nesto.hr> 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"> >> <!-- >> 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
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+',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 ! -- Stephane Moriaux et son (moins) vieux Mac dj dpass Stephane Moriaux and his (less) old Mac already out of date
Nicholas said:
>"scripts.contact" <scripts.cont@gmail.com> wrote in message >news:1178881669.842400.51010@e51g2000hsg.googlegroups.com... >> On May 11, 4:15 am, "Nicholas" <nikolaatponekaddo@nesto.hr> 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"> >>> <!-- >>> 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. --
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/bestpractices/#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/bestpractices/#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 Grard -- Using Web Standards in your Web Pages (Updated Dec. 2006) http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_...
|
 |
 |
 |
 |
|