This may seem a mad question but there is a genuine reason for it!
If someone visits my page: http://my-domain.com/my-page/
And then they change the url to: http://my-domain.com...page/#something (note the # symbol!)
Is there a way to detect this change using javascript?
They haven't clicked on a link to make this change (otherwise you could just use the onClick event of the link) they have typed into the address bar.
Detecting within-page links using js
Started by CygnetGames, Mar 22 2008 08:19 AM
2 replies to this topic
#1
Posted 22 March 2008 - 08:19 AM
|
|
|
#2
Posted 22 March 2008 - 02:15 PM
Well what do you want to do with that? Can you explain what would be the use of that? And I think that would be possible by breaking the URL using JS may be possible
#3
Posted 23 March 2008 - 02:23 AM
The application is an ajax search page.
The main point i'm trying to prove with this page is that ajax doesn't have to break the usability of a website. I want the user to be able to bookmark the page, use the forward and back buttons and send the url to a friend in ways that are familiar to them.
My first thought was to store the search criteria in the query string, but this breaks the ajax because changing the query string reloads the whole page from the server.
So my second thought was to make a fake "query string" after the # symbol (what's this part of the url called anyway?) like so:
http://my-domain.com...search_criteria
Because you can change this part of the url with javascript without the page being reloaded from the server.
This partly fulfils the requirements - the user can bookmark the page and send the url to a friend, and it will work as they expect.
But they can't use the forward or back buttons, or alter the url manually in the address bar.
So I need a way to detect, using javascript, when this portion of the url changes. I figured it must be possible, as the browser does something when it changes - normally it scrolls to the relevant section of the page.
And yes, I can break the url up using javascript - I need to do this when the page loads to parse the fake "query string".
The main point i'm trying to prove with this page is that ajax doesn't have to break the usability of a website. I want the user to be able to bookmark the page, use the forward and back buttons and send the url to a friend in ways that are familiar to them.
My first thought was to store the search criteria in the query string, but this breaks the ajax because changing the query string reloads the whole page from the server.
So my second thought was to make a fake "query string" after the # symbol (what's this part of the url called anyway?) like so:
http://my-domain.com...search_criteria
Because you can change this part of the url with javascript without the page being reloaded from the server.
This partly fulfils the requirements - the user can bookmark the page and send the url to a friend, and it will work as they expect.
But they can't use the forward or back buttons, or alter the url manually in the address bar.
So I need a way to detect, using javascript, when this portion of the url changes. I figured it must be possible, as the browser does something when it changes - normally it scrolls to the relevant section of the page.
And yes, I can break the url up using javascript - I need to do this when the page loads to parse the fake "query string".


Sign In
Create Account


Back to top









