Results 1 to 5 of 5

Thread: Always #top

  1. #1
    Join Date
    May 2005
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Always #top

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It can be done with Javascript:
    Code:
    <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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    May 2005
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •