View Full Version : Always #top
Haisook
09-28-2005, 05:02 PM
I want all my hyperlinks to open their corresponding pages, added to the url #top. I don't want to put it manually everytime I type the hyperlink.
Thanks
jscheuer1
09-28-2005, 05:23 PM
I don't think this can be done in HTML. Why do you want it? I ask because I wanted this once too except, back then I just went ahead and coded it into each link. I wanted it because I had the:
<a name="top"></a>
anchor a little ways down the pages and I liked the way a new page looked when it was scrolled slightly. Later I discovered that setting the top margin to 0 on the pages accomplished the same thing with much less coding and none of the jumpiness that the anchor method can sometimes cause. What is your reason?
It can be done with Javascript:
<script type="text/javascript">
var i, a = document.getElementsByTagName("a");
for(i=0;i<a.length;i++) a[i].href += "#top";
</script>
Not compatible with non-JS browsers. Make sure it's nothing vital. And yes, you would be better doing it manually or, better still, restyling the linked page.
Haisook
09-28-2005, 08:48 PM
Well, I need it because I'll be having 2 frames in my website. One is the menu, and the other contains the main content (articles). Each link in the former is supposed to open a page in the latter. So, when I scroll down the menu, and I click a link, I want the upcoming page to appear from its top, not from where I click the link in the menu.
Hope I was clear.
jscheuer1
09-29-2005, 03:44 AM
The new page opening in the 'content' frame from its top would be the default behavior if everything is as you have explained it and the new pages are independent pages and not themselves also frames pages. Perhaps a link to a demo that shows the problem would be in order.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.