Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 10th, 2007, 04:05 AM
Authorized User
Join Date: Sep 2006
Location: Cologne, , Germany.
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default Browser window: Specifying the size and location?

Hi everyone,

I know that I can specify the size of items/objects within the browser but would like to ask if it is possible, from within HTML code, to specify the initial size and position of the browser window?

We have a lot of fixed-width columns and so it would be great if I could do this so that the user then doesn't need to re-size the window to see the data.

Any tips or links to HOWTOs would be a great help.

Many thanks,
Alan Searle

PS: This is for IE6 sp1 but I'd be interested in the syntax for Firefox too.

Reply With Quote
  #2 (permalink)  
Old November 5th, 2007, 06:26 AM
Friend of Wrox
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post

If you give "width" attribute in "em" then the width of elements will automatically adjust to browser width.
For example
   <div style="border:pink 2px solid;width:60em;">
      <div style="width:25em; background-color:pink;float:left">Rakesh</div>
      <div style="width:34em; background-color:yellow;float:right">Rakesh</div>

- Rakesh
Reply With Quote
  #3 (permalink)  
Old November 22nd, 2007, 08:50 AM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts

There's no real way to do this in HTML. HTML provides the structure and content of your webpage. You're trying to take control of the browser window and adjust it's position and size. That falls under the page's behavior and is controlled with Javascript.

To get on my soapbox for two seconds, since there may be very good reasons that your visitor has their browser set up the way they do (especially if they have accessibility needs), I try never to mess with these factors. However, they are relatively simple elements of the DOM and "shouldn't" cause problems for most people, though there are other things you can do in Javascript that are. I originally learned Javascript from a tutorial at www.htmlgoodies.com and there are dozens of others. The functions you're trying to implement are pretty basic and probably wouldn't require more than about half an hour of study with a good javascript tutorial. www.w3schools.com is probably the place I'd start.

The important thing with Javascript is to reference it with a script tag at the end of the file like this.

<script type="text/javascript" src="Scripts/MyScript.js"></script>

Because of accessibility, SEO, and people with Javascript turned off, it's best practices to put ALL your javascript in a separate *.js file. And you have to call the script at the end of the document (unlike a lot of tutorials that may have you write your scripts embedded between the <head> tags at the top. That's better than writing inline scripts, but best practices is to separate the javascript out entirely.


Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting a fixed size browser window Loz Javascript How-To 12 April 18th, 2006 10:43 AM
Launch default browser in a new browser window haiying Beginning VB 6 1 August 30th, 2005 05:48 PM
window.location crmpicco Javascript 1 July 7th, 2005 08:55 AM
Window Size and DIV location TSEROOGY Javascript 6 August 30th, 2004 10:37 PM
Fonts and Browser window size freaky al Dreamweaver (all versions) 5 October 5th, 2003 11:07 AM

All times are GMT -4. The time now is 03:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.