I have a header.php which has my <a name='#top' />
and I have a footer.php which I want to do something like
if ($_SERVER[' is scroll bar ']
{
echo <a href='#top'>Back to Top</a>
}
is it possible with PHP or Javascript to do something like this, where I can know if my page is going to be very long ahead of render time?
First off, I’m unsure of the practical usefulness of such code. I’m never really certain what a “back to top” or “jump to top” link will do:
I do know what pressing the
Homekey will do, though, and I suspect most people would rather navigate a page using native controls if possible.Nonetheless, once the page is loaded, you could toggle that kind of link dynamically by setting up event handlers on page resize:
Different browsers — by which I mean IE versus everyone else — have their own ways of finding height, and so the above accounts for that, maybe somewhat redundantly.