Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / March 2005



Tip: Looking for answers? Try searching our database.

scrollbar

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Fastré - 31 Mar 2005 14:30 GMT
Hello

I want to display a link on the bottom of a webpage to go to the top,
but only if the user has to scroll down. If there's a small page, this
link has no use.

I'm using the following code (in the body onload)
    var wdb = window.document.body;
    var scrolling;
   
    if (wdb.scrollHeight > wdb.clientHeight) {
        //alert('Scrolling=True');
        document.getElementById('img_totop').style.visibility
            = 'visible';
    }
    else {
        //alert('Scrolling=False');
        document.getElementById('img_totop').style.visibility
            = 'hidden';
    }

It works on Internet Explorer, scrollHeight is bigger than clientHeight
with a long page.
But not in firefox, scrollHeight = clientHeight in all cases.
What can I do about it?

regards

Peter
McKirahan - 31 Mar 2005 14:44 GMT
> Hello
>
[quoted text clipped - 25 lines]
>
> Peter
McKirahan - 31 Mar 2005 14:45 GMT
> Hello
>
[quoted text clipped - 25 lines]
>
> Peter

Won't this work for you:

<body>
<a name="top"></a>
.
.
.
.
.
<a href="#top">top</a>
</body>

The link will always show but on a short page it does nothing.
Peter Fastré - 31 Mar 2005 16:32 GMT
> Won't this work for you:
>
[quoted text clipped - 9 lines]
>
> The link will always show but on a short page it does nothing.

I know, but I don't want the link to be shown, it makes no sense if the
page is short.

regards

Peter
McKirahan - 31 Mar 2005 16:47 GMT
> > Won't this work for you:
> >
[quoted text clipped - 16 lines]
>
> Peter

What dimension (in pixels) is a "short" page?

If the browser window is resized by the visitor
then the page may no longer be "short".
Peter Fastré - 31 Mar 2005 17:09 GMT
> What dimension (in pixels) is a "short" page?
>
> If the browser window is resized by the visitor
>  then the page may no longer be "short".
Short means to me, the page fits on the screen without scrollbars. It
makes no sense showing a top link in this case.
A long page means that the user has to scroll down to read everything,
causing the menu and navigation on top of the page to disappear. Users
want frames-websites, where navigation always stays on top. I have to
convince them not to use frames, and the 'top' link is one of my
arguments to drop the frames.

Regards

Peter
McKirahan - 31 Mar 2005 17:30 GMT
> > What dimension (in pixels) is a "short" page?
> >
[quoted text clipped - 12 lines]
>
> Peter

You didn't address my issue of resizing.

"Users  want frames-websites ..." --
are you talking about your Users (or all Users)?

A small "top" image that may not always be applicable
is preferable to the use of scripting that may be disabled.

Another argument against frames is how the print!
RobB - 31 Mar 2005 20:38 GMT
> Hello
>
> I want to display a link on the bottom of a webpage to go to the top,

> but only if the user has to scroll down. If there's a small page,
this
> link has no use.
>
[quoted text clipped - 14 lines]
>
> It works on Internet Explorer, scrollHeight is bigger than
clientHeight
> with a long page.
> But not in firefox, scrollHeight = clientHeight in all cases.
[quoted text clipped - 3 lines]
>
> Peter

This may need some fine-tuning.

window.onload = function()
{
var bShow,
el,
dHt = self.innerHeight ? self.innerHeight :
document.documentElement
&& document.documentElement.clientHeight ?
 document.documentElement.clientHeight :
document.body ? document.body.clientHeight : null;
if (dHt && 'undefined' != typeof document.body.scrollHeight)
{
 bShow = (document.body.scrollHeight > dHt);
 if (document.getElementById
 && (el = document.getElementById('img_t­otop')))
  el.style.visibility = bShow ? 'visible' : 'hidden';
}
}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.