Solved

how to obtain pixel height browser is using?

Posted on 1998-09-30
4
366 Views
Last Modified: 2013-12-25
How do I get the pixel height of the current browser?  I am trying to use this number to determing where to scroll to.
Thanks.
0
Comment
Question by:scretti
  • 2
4 Comments
 
LVL 2

Expert Comment

by:chrisbolt
ID: 1855351
In both browsers, the JavaScript variables that hold the entire screen's width and height (eg Monitor resolution, 640x480, 800x600, etc) is:

screen.width
screen.height

In Netscape 4 and above, the JavaScript variables that hold various values are below:

window.innerHeight (the height of the page in pixels)
window.innerWidth (the width of the page in pixels)
window.pageXOffset (where the user has vertically scrolled the page to, compared to the top of the page, in pixels)
window.pageYOffset (where the user has horizontally scrolled the page to, compared to the left of the page, in pixels)

In IE 4 and above, the JavaScript variables that hold these values are:

document.body.clientHeight (the height of the page in pixels)
document.body.clientWidth (the width of the page in pixels)
document.body.scrollLeft (where the user has vertically scrolled the page to, compared to the top of the page, in pixels)
document.body.scrollTop (where the user has horizontally scrolled the page to, compared to the left of the page, in pixels)

You can find these values and do stuff with them in JavaScript. An example is below:

<SCRIPT LANGUAGE="JavaScript">
<!--
if (screen.width == 640 && screen.height == 480) {
  document.write("Your resolution is set small! :-)");
}
else {
  document.write("Your resolution is set to " + screen.width + " by " + screen.height);
}
//-->
</SCRIPT>

If you need any more help, just email me at chrisbolt@email.com or just add a comment to this question...
0
 

Author Comment

by:scretti
ID: 1855352
Sorry,
I don't need the screen resolution, just the pixel height of the font.  For example:
If I have output dynamically writen to a new window and need to scroll to a point at every 25 lines for output of maybe 300 lines, I need to calculate how many pixels that would be.  I have tried every approach to dynamically writing local anchor tags and they do not work in Netscape because of the <base> tag Netscape puts in.  That question has been posted and exhausted.  So I'm forced to use a "hokey" window.scroll to accomplish this same effect but need a way to control exactly where each line will start in pixels.  Hope this clarifies.
Thanks,
Shawn Cretti
0
 

Author Comment

by:scretti
ID: 1855353
Adjusted points to 100
0
 

Accepted Solution

by:
maximi earned 100 total points
ID: 1855354
There's no *good* way of adapting your html to the resolution that might be in use dynamically. There are Java Applets and JavaScripts but I hate this, I wouldn't want to screw my site with this garbage, so what I (and lots more) do is to design a web page that looks good in 640X480 and doesn't suck in 800X600. This can be done with tables, design and small fonts.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now