View Full Version : href (?query#xyz) & refresh
03-02-2005, 12:01 AM
I was entertaining the notion of getting the search property from an anchor (for unnatural acts of scripting), but applying it seems to cause a document reload (when the anchor is clicked)...
Is this always to be the case, or can refreshing be prevented by an attribute somewhere?
03-02-2005, 02:38 AM
This is what I mean...
<a id="foo" href="?foo#bar">fBar</a> | <a id="bar" href="?bar#foo">barF</a>
var l = location, s = l.search.substr(1);
var h = l.hash.substr(1);
alert("now " + s + "ing a " + h + "...");
... but without the pesky on/reload (heck, I don't even know what queries are actually for; who does?). :D
03-02-2005, 02:49 AM
Googly moog fooger? Butter squash nut table fist? Ah, mug cable speaker board. Try:
:D okay, had to get it out. Your post was confusing the heck out of me until you posted the code, and it still sort of is...
The page isn't reloading, though, it's only being sent to the "href" specified in the link. So you click on "<a id="foo" href="?foo#bar">fBar</a>", for example, and it takes you to http://whatever/page.htm?foo#bar.
As far as no-refresh/reloading, there's no way to prevent that using strictly HTML or CSS. I'm sure there's another js way to do what you're trying to do without the page being sent somewhere, though...
03-02-2005, 03:03 AM
I dunno what to make of it... clicking an #anchor which has no ?query does not trigger the onload event--so it must be 'reloading' due to the query, right? :confused:
03-02-2005, 06:46 AM
Anyway, I sort of fixed the problem of "reloading", by making the function repeat itself: call#1 stores the search property in a global variable, erases it from the anchor, returns false on the event, and finally calls click() on the element--which triggers call#2 to restore the search property.
In this way, navigation works without a loss of state. :)
Where on earth can practical info about URL queries be located, I wonder...
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.