Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Width Of Display Area Of Browser Window, is there a formula?
Jeune
post Aug 9 2006, 01:02 AM
Post #1


Member [Level 2]
*****

Group: Members
Posts: 82
Joined: 20-October 05
Member No.: 13,144




I am making a table in a website that's as big as the display area of the browser for instance:

CODE

<Table border=0 cellpadding=0 cellspacing=0 width=?? align=center>
....
.....
</table>


How do I know the width of the browser display area? Better yet, is there a general formula for
that for other screen resolutions?

I know a little bit of javascript, are there functions for that?
Go to the top of the page
 
+Quote Post
Mich
post Aug 9 2006, 01:48 AM
Post #2


Trap17 Maverick
***********

Group: [HOSTED]
Posts: 1,088
Joined: 5-January 06
From: Michigan, USA
Member No.: 16,652



QUOTE(Jeune @ Aug 8 2006, 09:02 PM) *

I am making a table in a website that's as big as the display area of the browser for instance:
CODE
<Table border=0 cellpadding=0 cellspacing=0 width=?? align=center>
....
.....
</table>

How do I know the width of the browser display area? Better yet, is there a general formula for
that for other screen resolutions?
I know a little bit of javascript, are there functions for that?
Simple solution to the table width. Use percentages.
CODE
<Table border=0 cellpadding=0 cellspacing=0 width=100% align=center>
....
.....
</table>

This way it fits whatever width the browser is displaying. It does screw up the pages some if you have designed a page for 1024x768 and somebody is viewing say at 800x600.

Can't help you with the javascript question.
Go to the top of the page
 
+Quote Post
Jeune
post Aug 9 2006, 03:59 AM
Post #3


Member [Level 2]
*****

Group: Members
Posts: 82
Joined: 20-October 05
Member No.: 13,144



QUOTE(Mich @ Aug 9 2006, 09:48 AM) *

Simple solution to the table width. Use percentages.
CODE
<Table border=0 cellpadding=0 cellspacing=0 width=100% align=center>
....
.....
</table>

This way it fits whatever width the browser is displaying. It does screw up the pages some if you have designed a page for 1024x768 and somebody is viewing say at 800x600.

Can't help you with the javascript question.



It's hard to use that especially if I have the other tables within the larger table require that they be measured in pixels.

For instance, I want the large table to contain a separator (like cellpadding) of width 10px, how I am supposed to compute for the measurements of the other tables so that they add up to the larger table holding them?

here's a "graphic" explanation of my problem:

CODE

<Table border=0 cellpadding=0 cellspacing=0 width=100% align=center>
<tr><td=??>

<td width=10>

<td=??>

</table>


















Go to the top of the page
 
+Quote Post
rvalkass
post Aug 9 2006, 07:50 AM
Post #4


apt-get moo
Group Icon

Group: [MODERATOR]
Posts: 2,056
Joined: 28-May 05
From: Hertfordshire, England
Member No.: 7,593
Spam Patrol



Do you actually need a spacer? As you said, you can use cell padding, or use CSS to change the margins and padding of the cells to get it to work if all you want is space. If it needs a different background or something, then you will need a separate cell.

I think there are 3 ways of using Javascript to get the width and height of the browser window, but I strongly advise you not to use them. They can cause all sorts of bugs, especially if JS is turned off and then people won't see your site at all.

CODE

Method 1:
window.innerHeight
window.innerWidth

Method 2:
document.documentElement.clientHeight
document.documentElement.clientWidth

Method 3:
document.body.clientHeight
document.body.clientWidth


They all return the width or height of the browser window in pixels, but there are problems. With the first one, IE returns nothing so people still using Internet Explorer either won't see the site, or will see a garbled mess. Method 2 will get a result from IE, but it's 0 for v5 or 6 in quirks mode. Method 3 gets a result from everything bar Netscape, but some browsers offer the internal size not including scroll bars, some offer internal size including scroll bars and some give the size of the whole window. This is why I advise using either a fixed width table centralised in the page or setting the table to a width of 100%.
Go to the top of the page
 
+Quote Post
fffanatics
post Aug 9 2006, 02:41 PM
Post #5


Privileged Member
*********

Group: [HOSTED]
Posts: 937
Joined: 14-April 05
From: West Chester, PA
Member No.: 5,636



Javascript is not the answer for a table width problem like this. It has too many restrictions based on the browser being used. What you are going to want to do is use width="100%" and if you are going to set the pixel width of any tr's or td's inside the 100% width table, be warned that if the screen is too small for the set widths specified, a scrollbar will be inserted.
Go to the top of the page
 
+Quote Post
mynitr
post Aug 9 2006, 03:11 PM
Post #6


Newbie [Level 2]
**

Group: Members
Posts: 31
Joined: 8-August 06
Member No.: 27,978



Ya,
Use "percentage" instead of "pixels" while mentioning the table/cell dimentions.
For example, let's talk about the width.
100% width means the width of display. So if you are putting some image file in a particular table cell give it's size in pixels and the remaining space is now 100%. Divide it with the other cells/tables.
Go to the top of the page
 
+Quote Post
beeseven
post Aug 26 2006, 06:25 PM
Post #7


Privileged Member
*********

Group: Members
Posts: 629
Joined: 26-February 05
Member No.: 3,995



10px on 1024x768 (I think that's what most people use, isn't it?) is just about 1%, so couldn't you have the width of the table as 100% and the spacers 1%?
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Table Width Help(2)
  2. Opening Images In Pictureviewer Instead Of Browser(7)
  3. Display Tooltip(2)
  4. How To Reference Parent Browser Window From.....(2)
  5. Max Table Width(13)
  6. Trouble With Links On A List(7)
  7. Word.doc Or Pdf Formatted File To Display In A Web(12)
  8. Browser Altering Font Size(6)
  9. Ie Table Width In A Div Tag(4)
  10. Centering Page Of Html At Various Display Widths(14)
  11. How To Make Youtube Embedded Videos Viewable On All Browsers(3)
  12. Creating Rss Feeds For Wapsites(5)
  13. How To Display Php Code [resolved](8)


 



- Lo-Fi Version Time is now: 26th July 2008 - 06:00 PM