[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to obtain pixel height browser is using?

Posted on 1998-09-30
4
Medium Priority
?
390 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 200 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

656 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