473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Body attributes...

Can someone tell me if there is a universal way to check the available
screen with and screen height for IE, Netscape, and Opera? Is there a
universal syntax? Thanks in advance.

Tony
Jul 20 '05 #1
5 3697
"Tony Vasquez" <co**********@earthlink.net> writes:
Can someone tell me if there is a universal way to check the available
screen with and screen height for IE, Netscape, and Opera? Is there a
universal syntax? Thanks in advance.


screen.availWidth
and
screen.availHeight
Works in Netscape 4+, Mozilla, Opera 4+ (haven't tested Opera 3), amd
IE 4+. That is, probably in all current browsers.

The next questions is: What do you need it for? If it is a publically
available web page (not an intranet) then you probably don't need the
screen resolution for anything. E.g, Opera in MDI mode is completely
unaffected by the screen resolution, since all Opera page windows are
constrained by the application window. If you try to use the screen
size for anything, it will probably be unreadable.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Actually, I don't want the screens available width, I'm sorry, I meant the
browsers available width. What I am trying to do is center a DIV vertically
as well as horozontally. Can you help further?

Tony
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in message
news:u1**********@hotpop.com...
"Tony Vasquez" <co**********@earthlink.net> writes:
Can someone tell me if there is a universal way to check the available
screen with and screen height for IE, Netscape, and Opera? Is there a
universal syntax? Thanks in advance.
screen.availWidth
and
screen.availHeight
Works in Netscape 4+, Mozilla, Opera 4+ (haven't tested Opera 3), amd
IE 4+. That is, probably in all current browsers.

The next questions is: What do you need it for? If it is a publically
available web page (not an intranet) then you probably don't need the
screen resolution for anything. E.g, Opera in MDI mode is completely
unaffected by the screen resolution, since all Opera page windows are
constrained by the application window. If you try to use the screen
size for anything, it will probably be unreadable.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'

Jul 20 '05 #3
"Tony Vasquez" <co**********@earthlink.net> writes:
Actually, I don't want the screens available width, I'm sorry, I meant the
browsers available width. What I am trying to do is center a DIV vertically
as well as horozontally. Can you help further?


The FAQ has an entry on finding the browser size:
<URL:http://jibbering.com/faq/#FAQ4_9>

I wouldn't use Javscript to center an element, though. CSS is there for
that.

You should also consider what you mean by "centering vertically". If
the document is longer than the viewport, what should the element be
centered wrt.? However, the usual use for vertical centering is to
position a div containing the entire content of the page (which I have
*never* understood. Why not use all the available space instead of
showing ones page as a stamp-sized box in the middle of an empty page).

There are several ways to center a div wrt. the page.

The most correct, according to standards, is with the following CSS:

<style type="text/css">
body,html {height:100%; /* makes document as high as the viewport */ }
div.centered {
margin:auto;
width:640px;
height:480px;
}
</style>

However, older borwsers, especially older IE's, have proplems with
auto margins. The trick that is often used in IE is more dangerous.
It positions the element with the top at the center and the uses
a negative margin to pull it up.

<!--[if IE]>
<style type="text/css">
body,html {height:100%;}
div.centered {
margin:0px;
position:absolute;
width:640px; /* positions element at 320px left of the center */
left:50%; /* */
margin-left:-320px; /* */
height:480px;
top:50%;
margin-top:-240px;
}
</style>
<[end if]-->

This method is more dangerous, because a small screen can make the
negative margin position the element above the top of the page (or to
the lef tof the left side). You cannot scroll there, so the content is
lost.

I recommend against vertical centering in these cases.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
How about using a single-celled table?

[table width="100% height="100%" border="0"]
[tr]
[td align="center" valign="middle"]CONTENT HERE[/td]
[/tr]
[/table]

Tony Vasquez wrote:
Actually, I don't want the screens available width, I'm sorry, I meant the
browsers available width. What I am trying to do is center a DIV vertically
as well as horozontally. Can you help further?

Tony


Jul 20 '05 #5
Lewis Shadoff wrote:
How about using a single-celled table?

[table width="100% height="100%" border="0"]
[tr]
[td align="center" valign="middle"]CONTENT HERE[/td]
[/tr]
[/table]
Misuse of tables. A table is a table is a table. [tm]
Do not use it for layout.
[Top post]


Don't do that, either.
PointedEars
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Frances Del Rio | last post by:
when I test my stuff with the validator in HomeSite it tells me the body tag no longer reads margin attributes.. does this mean now margins are to be specified only in CSS? I work for an...
1
by: Chris Millar | last post by:
wondered if anyone could help me - i'm trying to control the value of an attribute of the BODY tag on a page. So i've got: <html> <body test="colin"> <form ...... ** content ** </form>...
2
by: James Cooke | last post by:
I want to set body attributes programmatically, from the module file: I can go into the .aspx file and say <body onload="myFunc()"> but I don't want to. Like you do with a textbox control: ...
8
by: localhost | last post by:
I would like to wrap all of the HTML inside of my <body> tag inside a <div> with in my code-behind. I do not want to touch the .aspx page template at all. I know how to make the body tag...
2
by: Joy | last post by:
Hi all I know that I can use the following code to add some script-code to a button button.Attributes("onclick") = myscript I like to do the same for the page itself as ("onload") =...
3
by: Alan No Spam | last post by:
I am using Visual Studio 2003 and in order not to repeat body tag details in every page <body leftmargin=0 topmargin=0 .... I put those details as an variable in my class: public class...
1
by: jiatiejun | last post by:
I want to add BODY Attributes example: from <bodyto <body leftmargin="0" topmargin="0" or from <bodyto <body onload="window_onload()" how to set the BODY ?
5
by: mazdotnet | last post by:
Hi, I have a master file with the following setting <body runat="server" id="Body"> and in the .cs I have Body.Attributes.Add("onload", "menuCurrentPage('current','navlist');"); Now in one...
6
by: _Who | last post by:
I use the code below to change to a style sheet that has: body { ....
4
by: _Who | last post by:
In the .master file I have: <body runat="server" id="MainBody"> I need to add a background attribute to MainBody in the .master.vb file. But there it tells me that MainBody is not declared. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.