Forum Moderators: open
What i'm trying to do is load html content that i have stored in an "includes" folder into a div on my index page when clicking a link i a menu that is in another div on my index page, the said menu is also in the "includes" folder and called into my index page using the php include function.
I've managed a couple of ways of doing this using a couple of jquery snippets i found on the web which have worked with some success. But what i'm truing to do is change the url when new content is loaded into the div. eg. when a link is clicked on "www.mydomain.com" "newcontent.html" is loaded into my content div and the url changes to "www.mydomain.com/newcontent.html" i've been told by a good few people that yes, it is possible but i have yet to find the correct method of doing this.
If anyone here can help me accomplish this i would be very greatful.
Thankyou in advance,
If you change the URL in the address bar, the browser will navigate to that new URL. Otherwise, you'd have a big security threat, as someone could do something like create a page with a fake link to, say, a bank login page, trying to make it appear to the user that they were on the bank login page when in fact they were on a "spoofed" page.
So the answer is no, you can't change the URL (without actually navigating to that URL).
So, you can't change the URL from this:
http://www.example.com/
To this:
http://www.example.com/newcontent.html
without redirecting the browser.
But you can change the URL from this:
http://www.example.com/
to this:
http://www.example.com/#newcontent.html
without redirecting.
Perhaps that's what those few good people were referring to? :)
var h = location.hash;
If it's got a value, pull in that document as you normally would if someone clicked on it. And then make sure all of your links that pull in documents are configured with an href value like:
href="#newcontent.html"
Hope that helps.