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

window.open

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
AU
Hi...I have the following javascript code below. It is not working obviously as its not reading the screen width and screen height variables

Am i doing something wrong?

Thanks in Advance

screen_width = screen.width;
screen_height = screen.height;

win=window.open("","IRC","resizable=yes,height='+screen_height +',width='+screen_width +'700,screenX=0,screenY=0,left=0,top=0")
 
Just a simple point, maybe it is a little to obvious, but shouldn't your line have "'s as shown in red:

win=window.open("","IRC","resizable=yes,height='"+screen_height +"',width='"+screen_width +"'700,screenX=0,screenY=0,left=0,top=0") DeltaFlyer ;-)

DeltaFlyer - The Only Programmer To Crash With Style.
 
teroy ..

A better way of doing this is to build up your attribute list in a string first, and then use that in the win.open method. So you would have a javascript function something like ;
Code:
function openWin()
{
  var screenWidth=screen.width;
  var screenHeight=screen.height;
  var optStr="resizable=yes, width=" + screenWidth + ",height=" + screenHeight + ",screenX=0,screenY=0,left=0,top=0";
  
  myWin=window.open("","IRC",optStr);
}
and then when you want to open a new window, you just need to call the function from the appropriate place. For example if it's a hyperlink to click, you would do something like ;
Code:
<A HREF=&quot;javascript:openWin();&quot;>Click Here</A>
or
Code:
<A HREF=&quot;#&quot; onClick=&quot;openWin();&quot;>Click Here</A>
Hope this helps ...

Greg.
 
Thanks guys. Your suggestions worked :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top