Solved

how to obtain pixel height browser is using?

Posted on 1998-09-30
4
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

691 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