system — 2008-06-04T17:37:42-04:00 — #1
I want to change this:
I dont need to change the address, just the stuff after it.
and for future reference, what is the technical name for the stuff after the address?
Thanks as always
jimmyp — 2008-06-04T17:49:45-04:00 — #2
All the stuff following the "?" is called the query string. Everything following the hash symbol ("#") is normally refered to as the hash value.
It is possible to change the hash value without refreshing the page but not the query string.
See this thread: http://www.sitepoint.com/forums/showthread.php?t=552076
felgall — 2008-06-04T17:51:03-04:00 — #3
system — 2008-06-04T18:00:30-04:00 — #4
I see, thank you for such a quick reply.
So you can change the hash value without refreshing the page? I think I can work with that.
raffles — 2008-06-04T19:45:12-04:00 — #5
Yes, that would be the equivalent of clicking a link like this:
<a href="#furtherinfo">Further info</a>
Which would take you to the part of the page where there is an element with the ID "furtherinfo", e.g.:
It doesn't take you to a different page so it isn't a security issue.
system — 2008-06-05T07:40:43-04:00 — #6
Ive been having a play, and I've got stuck with something. I cant seem to stop the jumplinks from working, I need to disable them.
What I am doing is converting a html document with jumplinks, into a document where you can navigate through each section as a page. The html of other pages is still there, its just hidden with css ( display: none; ). Ive done it this way to help with accessibility.
raffles — 2008-06-05T09:08:38-04:00 — #7
You need to prevent the default action (which is to follow the link's href attribute), using preventDefault() for good browsers and returnValue for IE. See this:
system — 2008-06-05T09:37:32-04:00 — #8
Thanks, I really appreciate your help
paul_wilkins — 2008-06-05T21:27:16-04:00 — #9
Using the scrollTo technique is a more complex solution.
W3C has the preventDefault() method while IE has the returnValue property.
You don't need either though as returning false is also guaranteed to work.
Putting Occam's razor at work here, returning false is the simplest means by which to successfully do the job.
On the flip-side, if you do use the scrollTo method, you will in 6 months time have forgotten why it's there so you will need to either document that statement by placing a comment near it to remind you why.
Simple is best. return false and you or anyone else will be able to tell what's happening there.
raffles — 2008-06-07T06:53:31-04:00 — #10
Also, scrollTo(0,0) would jump up to the top of the page if the link you're clicking is somewhere you scrolled to down the page.
system — 2008-06-08T03:41:36-04:00 — #11
You know, I've been scratching be head over a similar issue. I want to take the query string off the URL without refreshing the page. Is that possible, or would that count as changing the location? I can see how it might be a security issue.
raffles — 2008-06-08T06:44:04-04:00 — #12
Yes, it would count as changing the location. The only thing you can do without leaving the page is change the characters after the hash symbol (#).
system — 2008-06-08T09:18:39-04:00 — #13
Ah ok, thank you.
can you not just disable the code that interacts with the query string, removing the need for removing the query string (to an extent)?
kronikmedia — 2008-06-08T09:40:52-04:00 — #14