Forum Moderators: open
<a href="#" onclick="return true;">Foo</a>
Should this result in another trip to the server? I always thought that because the href value only contained the # and not another URL, that it owuld be smart enough to know that it should search the current page for the link. However, I have some pages that pass in a value via the querystring and that value is used to retreive some data. When I click on a link like this, the data goes away because it hits the server again without the querystring value. Is this normal?
I know that putting "return false;" in the onclick event should prevent the server hit, but I didn't think it was necessary here. :-/
<base href="http://example.com/"> on your page? Are you using Opera as your browser? (If so, check out this thread [webmasterworld.com] from earlier today.)
So if I have a base tag like this:
<base href="https://localhost/foo/bar.htm">
But the location in my address bar looks like this:
[localhost...]
Then when I click on one of the links that has "#" as the href value, that equates to the URL in the base instead of the one with the query string.
Thanks, this has really helped!
This attribute specifies an absolute URI that acts as the base URI for resolving relative URIs.
As "#" is a relative URL, the base href will override any query string you may have.
If you can use server side scripting on your page, you could put the REQUEST_URI environment variable in front of your name link to resolve the problem (worked for me!)
As "#" is a relative URL, the base href will override any query string you may have.
Note, "#" is a fragment, not a querystring. What I want is for my base URL to contain the entire path, including query string. Including the query string does not make it a relative URL.
As defined in RFC 1808 Relative Uniform Resource Locators [ietf.org]:
absoluteURL = generic-RL ¦ ( scheme ":" *( uchar ¦ reserved ) )
generic-RL = scheme ":" relativeURL
relativeURL = net_path ¦ abs_path ¦ rel_path
rel_path = [ path ] [ ";" params ] [ "?" query ]
Thus, absoluteURL could be:
scheme ":" path "?" query
or
https://localhost/foo/bar.htm?id=1
This is also reinforced in RFC 2396 URI Generic Syntax [ietf.org], section 3. URI Syntactic Components.
I just wanted to clear up any confusion. It sounds like I should be able to specify a base that includes the querystring, so I think that may work for me.
Note, "#" is a fragment, not a querystring.
Indeed - I wasn't suggestion it was a query string! I was just describing why the base href caused the problems in the first place. # relative to [localhost...] [localhost...]
<base href="http://localhost/foo.htm?id=2">
As you suggest, this will solve your problem since it will link to http*//localhost/foo.htm?id=2#. I suggested using REQUEST_URI as an alternative, since you could add this into any number of links without the need for having different base href tags.