473,748 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.scrollba rs.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 3795
anna wrote:
How to tell if a horizontal scrollbar is present? I only want to use
scrollTo if horizontal scrollbar is present.
window.scrollba rs.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 showscrollfeatu res() {
var msg = 'clientHeight ' + window.document .body.clientHei ght + '\n';
msg += 'clientWidth ' + window.document .body.clientWid th + '\n';
msg += 'offsetHeight ' + window.document .body.offsetHei ght + '\n';
msg += 'offsetWidth ' + window.document .body.offsetWid th + '\n';
msg += 'scrollHeight ' + window.document .body.scrollHei ght + '\n';
msg += 'scrollWidth ' + window.document .body.scrollWid th + '\n';
msg += 'scrollLeft ' + window.document .body.scrollLef t + '\n';
msg += 'scrollTop ' + window.document .body.scrollTop + '\n';
alert(msg);
}

function scrollbarcheck( ) {
var scrolling;
if ((window.docume nt.body.scrollH eight >
window.document .body.clientHei ght) ||
(window.documen t.body.scrollWi dth >
window.document .body.clientWid th))
scrolling='true ';
else
scrolling='fals e';
alert('scrollin g='+scrolling);
}

Mike

Jul 23 '05 #2
mscir wrote:

Sorry, that should have been:

function showscrollfeatu res() {
var wdb = window.document .body;
var msg;
msg += 'clientHeight ' + wdb.clientHeigh t + '\n';
msg += 'clientWidth ' + wdb.clientWidth + '\n';
msg += 'offsetHeight ' + wdb.offsetHeigh t + '\n';
msg += 'offsetWidth ' + wdb.offsetWidth + '\n';
msg += 'scrollHeight ' + wdb.scrollHeigh t + '\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.scrollHei ght > wdb.clientHeigh t) ||
(wdb.scrollWidt h > wdb.clientWidth ))
alert('Scrollin g=True');
else
alert('Scrollin g=False');
}

Jul 23 '05 #3
FOLLOWUP
if (navigator.appN ame.indexOf("Ne tscape") != -1 &&
parseFloat(navi gator.appVersio n) < 5 ) {
if (document.width > window.innerWid th) {
document.write( '<a
href="javascrip t:window.scroll To(1000,window. pageYOffset)">< 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.c lientWidth) {
document.write( '<a
href="javascrip t:window.scroll To(1000,documen t.body.scrollTo p)"><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******* *******@Pointed Ears.de>
PointedEars
Jul 23 '05 #5

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

Similar topics

1
15629
by: Pal Csepregi | last post by:
Hi can i remove somehow the horizontal scrollbar? just the horizontal! Thx PallR
5
11193
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 scrollbar disappear and never come back again, because the content is "liquid". Resizing the window/viewport vertically, makes the scrollbar come back again. IE and Opera don't show this behaviour. Page: http://www/lahaina.nl/index.htm CSS:...
1
6695
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 style attribute of the panel element). Now when I dynamicly add controls to the Panel control the controls are getting places at the next line (I did not add a <br>) instead of at the same line (the horizontal scrollbar should appear now). I...
1
2943
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 disappears and all my content resizes, which obviously I don't want. I know I can use overflow: auto on the div, but that shows a horizontal scrollbar as well, and I don't need that - and because it's obvious I don't
4
2962
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 Horizontal Scrollbar
2
104892
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 vertical scrollbar when the area contains a too long text. IE wil just break off the text at the limit if a single word is too long and put the next character on the next line. For me this is the desired bahaviour (those horizontal scrollbars take too...
14
3953
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 using frames...) The main frame has to show a vertical scrollbar if content is bigger than one display page. This works well, but:
1
9339
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 way to hide the vertical scrollbars and display horizontal scrollbars?
3
5960
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 work correctly, I need the AutoScroll to not enable the horizontal scrollbar. After researching MSDN, I found the HScroll which can be used to disable horizontal scrolling when the AutoScroll mode is enabled. However, when I disable HScroll,...
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.