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!

Specifying HTML window width 1

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
Is it possible to specify the width of the first browser window (index.htm)? I would like the window to open on the left side of the screen with a width of say 35% of the screen.

Any help would be much appreciated. Thanks.
 
Function in the head:
Code:
function test()
{
window.moveTo(0,0);
var winW = (screen.width*0.35);
var winH = (screen.height*.35);
window.resizeTo(winW, winH);
}

In the body tag:
Code:
<BODY ONLOAD=&quot;test()&quot;>
&quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
Works great! Many thanks Bentley22. as an after-thought would it be possible to be able to position the window at the right side of the screen without needing to know the users screen size? Thanks again.
 
Quite possible:
Code:
function test()
{

var winW = (screen.width*0.35);
var winH = (screen.height*0.35);
var winX = (screen.width - winW);
var winY = 0;
window.moveTo(winX, winY);
window.resizeTo(winW, winH);
}
&quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
Just a quick bug note, this will work in IE and Opera, but it won't move to the right hand side in Netscape 4.7, 6.01. Seems to be a problem with the .moveTo function. &quot;The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us&quot;
Bill Watterson, Calvin & Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top