I’m developing a web-facing application where the data includes a great deal of externally generated HTML. In that HTML, there are a great many anchors and links pointing to those anchors, like this:
http://server/db.nsf/viewname/keyvalue#anchor
This part works well. However, I find myself in the situation of sometimes needing to set up dynamically generated links and/or redirections based on the anchor, and I can’t for the life of me figure out how to capture that anchor value. It’s not showing up in the CGI variables that I’ve looked at. I can get the first part of the url:
http://server/db.nsf/viewname/keyvalue
…but what I need is the “#anchor” part. I also can’t find an @formula which produces it. I suppose I could switch to JavaScript, but I’d rather not if I can avoid it. Am I overlooking something?
Subject: RE: Capturing anchors
If you’re already on the page and you click an anchor link to the same page, there’s no need for the request to be submitted to a server at all. The page is up on the screen already – the only work the browser has to do is scroll to the right part of it. So neither your server code, nor any JavaScript code, is likely to execute in this situation.
Just guessing here, but I suspect the browser also detects the anchor as part of the URL and doesn’t send it to the server when requesting a page. The page contents aren’t supposed to vary when you just change the anchor, so the server shouldn’t need that information.
The browser, likewise, caches pages based on the part of the URL not including the anchor. It would be silly to have the same page cached a dozen times when all you’re doing is navigating around it.
Plus, what if the user just uses PgDn to get around? You want something different to happen when they scroll this way, versus scrolling with anchor links?
Subject: RE: Capturing anchors
I’m not doing navigation on a single page. I need to navigate to similar anchors on different pages. At any rate, that explanation makes sense, and I’ve come up with a JavaScript solution which gives me what I need.