Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts

    href (?query#xyz) & refresh

    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?
    Last edited by codegoboom; 03-02-2005 at 12:19 AM. Reason: make any sense?
    *this message will self destruct in n-seconds*

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is what I mean...

    Code:
    <body onload="arrggg()">
    <a id="foo" href="?foo#bar">fBar</a> | <a id="bar" href="?bar#foo">barF</a>
    <script type="text/javascript">
    function arrggg()
    {
    	var l = location, s = l.search.substr(1);
    	if(s.length)
    	{
    		var h = l.hash.substr(1);
    		alert("now " + s + "ing a " + h + "...");
    	}
    }
    </script>
    </body>
    ... but without the pesky on/reload (heck, I don't even know what queries are actually for; who does?).
    Last edited by codegoboom; 03-02-2005 at 02:47 AM. Reason: oops
    *this message will self destruct in n-seconds*

  • #3
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    Googly moog fooger? Butter squash nut table fist? Ah, mug cable speaker board. Try:
    Code:
    boogerly {
     fooging: poinkersquit;
     }

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

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    *this message will self destruct in n-seconds*

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...
    Last edited by codegoboom; 03-02-2005 at 09:02 AM. Reason: eventually, I'll get it
    *this message will self destruct in n-seconds*


  •  

    Posting Permissions

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