473,387 Members | 1,687 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.

scrollTo only if horizontal scrollbar

How to tell if a horizontal scrollbar is present? I only want to use
scrollTo if horizontal scrollbar is present.

window.scrollbars.visibility doesn't specify which scrollbar is
present, so it gives a false result if there is vertical scrollbar but
not horizontal scrollbar.

TIA,
Anna
Jul 23 '05 #1
4 3756
anna wrote:
How to tell if a horizontal scrollbar is present? I only want to use
scrollTo if horizontal scrollbar is present.
window.scrollbars.visibility doesn't specify which scrollbar is
present, so it gives a false result if there is vertical scrollbar but
not horizontal scrollbar.
TIA,
Anna


You could give this a try, check for scrollWidth > clientWidth.
It works for my IE6, Netscape 7.1, Firefox 0.8.

function showscrollfeatures() {
var msg = 'clientHeight ' + window.document.body.clientHeight + '\n';
msg += 'clientWidth ' + window.document.body.clientWidth + '\n';
msg += 'offsetHeight ' + window.document.body.offsetHeight + '\n';
msg += 'offsetWidth ' + window.document.body.offsetWidth + '\n';
msg += 'scrollHeight ' + window.document.body.scrollHeight + '\n';
msg += 'scrollWidth ' + window.document.body.scrollWidth + '\n';
msg += 'scrollLeft ' + window.document.body.scrollLeft + '\n';
msg += 'scrollTop ' + window.document.body.scrollTop + '\n';
alert(msg);
}

function scrollbarcheck() {
var scrolling;
if ((window.document.body.scrollHeight >
window.document.body.clientHeight) ||
(window.document.body.scrollWidth >
window.document.body.clientWidth))
scrolling='true';
else
scrolling='false';
alert('scrolling='+scrolling);
}

Mike

Jul 23 '05 #2
mscir wrote:

Sorry, that should have been:

function showscrollfeatures() {
var wdb = window.document.body;
var msg;
msg += 'clientHeight ' + wdb.clientHeight + '\n';
msg += 'clientWidth ' + wdb.clientWidth + '\n';
msg += 'offsetHeight ' + wdb.offsetHeight + '\n';
msg += 'offsetWidth ' + wdb.offsetWidth + '\n';
msg += 'scrollHeight ' + wdb.scrollHeight + '\n';
msg += 'scrollWidth ' + wdb.scrollWidth + '\n';
msg += 'scrollLeft ' + wdb.scrollLeft + '\n';
msg += 'scrollTop ' + wdb.scrollTop + '\n';
alert(msg);
}

function scrollbarcheck() {
var wdb = window.document.body;
var scrolling;
if ((wdb.scrollHeight > wdb.clientHeight) ||
(wdb.scrollWidth > wdb.clientWidth))
alert('Scrolling=True');
else
alert('Scrolling=False');
}

Jul 23 '05 #3
FOLLOWUP
if (navigator.appName.indexOf("Netscape") != -1 &&
parseFloat(navigator.appVersion) < 5 ) {
if (document.width > window.innerWidth) {
document.write('<a
href="javascript:window.scrollTo(1000,window.pageY Offset)"><img
src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
}
} else {
if (document.body.scrollWidth > document.body.clientWidth) {
document.write('<a
href="javascript:window.scrollTo(1000,document.bod y.scrollTop)"><img
src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
}
}
Jul 23 '05 #4
anna wrote:
[nonsense again]


See <news:40**************@PointedEars.de>
PointedEars
Jul 23 '05 #5

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

Similar topics

1
by: Pal Csepregi | last post by:
Hi can i remove somehow the horizontal scrollbar? just the horizontal! Thx PallR
5
by: Jsp | last post by:
I created a vertically scrolling div. On initial rendering, Firefox shows a horizontal scrollbar in this div, over the complete width. Resizing the width of the window/viewport makes the horizontal...
1
by: Marco Liedekerken | last post by:
Hi, I want a Horizontal scrollbar to appear in my Panel control when I add new controls to it (when the width is getting too big). The Vertical scrollbar is easy (adding overflow: auto to the...
1
by: dhnriverside | last post by:
Hi guys I'm using a div to create a list with ajax stuff. At the moment, the div shows a scrollbar if the content is larger than the div. The problem is that if it isnt, the scrollbar...
4
by: Sakharam Phapale | last post by:
Hi All, I have installed VS .NET 2002 on my machine. I have checked both Vertical scrollbar and Horizontal Scrollbar options, in Tools -> Options-> Text Editor-> General-> Vertical Scrollbar...
2
by: musicmouse | last post by:
Happy new year to you all, I have a problem with the css settings for the horizontal scrollbar of a textarea. When I look at my textarea's in Internet Explorer (I use 5.5) I see only a...
14
by: Michael Weis | last post by:
Hello all, as a non-professional in these things, I searched for this topic but found no satisfying answer: I have to create a site with 3 frames. (Please no diskussion about the sense of...
1
by: malpani.abhijit | last post by:
Hi, I am having a ListView component in my WinForm, when i add some images into it, it gives me a vertical scroll bar. What i want is, the horizontal scrollbar instead of vertical. Is there any...
3
by: j0rd4n | last post by:
I have a user control that needs to allow vertical scrolling but not horizontal scrolling. In the user control's resize event, I need to adjust the size of all the children controls. For this to...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.