in reply to Simulating internal anchors

What do you mean "I" in "I would like to be able to jump"?

If you mean in the same page, you can certainly say:

<a name="fred">About fred.</a> ... <a href="#fred">Back to fred.</a>
If you mean something else, you should say so.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: &bull;Re: Simulating internal anchors
by Elliott (Pilgrim) on Dec 01, 2002 at 23:22 UTC
    I plead guilty to anthropomorphizing my code!

    What I mean is that I want the page to load and immediately scroll to a point half-way down - as if it had been called via http with an internal anchor on the end of the URL.

    My latest idea is to put some JavaScript at the bottom of the page thus:

    <script language="JavaScript"> <!-- self.location.href='#ANCHOR'; //--> </script>

    and use a regexp to replace "ANCHOR" with "fred".

    Early indications are that this works - but - urgh! - JavaScript... A Perlier solution is still sought!

      My first reaction: just don't do it. Who are you to say where to scroll my browser? I hate web sites that "take over the driving" from me.

      My second reaction: you can do it, at the cost of one redirect. You had the right idea. Print an external redirect that includes an anchor on the first hit, but include a flag so you don't keep looping. On the re-fetch from the browser, generate the appropriate stuff, and put the anchor in the right place.

      But please, just don't do it.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.