Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2008, 08:38 PM   PM User | #1
markkanning
New Coder

 
Join Date: Nov 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
markkanning is an unknown quantity at this point
Change address bar for AJAXed links

Hello all,
I'm sure this is coming up quite a bit so maybe someone's got the answer...
How does one change the text of the address bar to reflect a page change implemented with AJAX?

In other words, I've got a small site where all the pages are AJAXed into through the index page. However, using PHP/Javascript, I've managed to cobble a function that will change the page given the presence of a page variable in the url string:
Code:
//HOME PAGE URL
http://www.mysite.com

//INSIDE PAGE
http://www.mysite.com/?page=contact
That all works fine. However, how can I have javascript change that page variable in the address bar when someone clicks on a link that is ajaxing a page in?

NOTE: using window.location.hash is not an option as I need to pass a variable for PHP reasons. Any non-hash alternatives?
markkanning is offline   Reply With Quote
Old 03-11-2008, 12:42 AM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,468
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
using the search param (?), instead of the hash (#) will cause all current browsers to refresh the page, not something i think you want.

so, in order to use a url, it would have to be a hash.

this means that you need to create a 'landing page'- a simple html/js page the immediately converts the hash to a search and transfers the url to your php script.

note that this would be incoming only; bookmarking a dynamic page would use the search, not the hash. make sure your server can find both versions.

edit:
one more idea: use ?s and a full-screen iframe to show your content. the hash of your top page can change while the search of the iframe changes
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:05 PM.


Advertisement
Log in to turn off these ads.