Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2007, 04:05 AM
Authorized User
 
Join Date: Sep 2006
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.


 
Old November 5th, 2007, 06:26 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you give "width" attribute in "em" then the width of elements will automatically adjust to browser width.
For example
Code:
<html>
 <body>
   <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>
   </div>
 </body>
</html>

- Rakesh
 
Old November 22nd, 2007, 08:50 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

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>
</body>
</html>

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.





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





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