PDA

View Full Version : Dynamically loaded content, with browser functions?



Quizosde
March 12th, 2007, 12:09 AM
I have links dynamically loading external page content into a div, with javascript, using script from the following tutorial:

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

I've got it working great, but my question is this: Is there anyway to have this type of navigation while maintaining browser functions(back, forward). I'd also like someway to have an absolute address for the each page section. Right now you just go to the index.html, and it just stays there while you load content into the divs.

Any ideas?

Surrogate
March 13th, 2007, 08:52 PM
Nu-uh. You can't maintain the browser functionality without doing reloads. Which isn't AJAX.

You gotta create your own functionality in your AJAX application, if you want such functionality.

Concerning absolute adresses - nu-uh, you cannot change the address without reloading. Alternatively you can chose to reload at certain important spots to allow bookmarking and what not, and still keep the main interactivity in a AJAX format.

I recommend having all pages in classical structural format - so a user without JS can navigate the page effortlessly. Just have each page have an identifier (Maybe a <body id="Mainpage">) that your JS can catch, and use to fill the page with the correct content. This will also allow direct linking to AJAX content - maybe for AJAX controlled bookmarks.

AJAX is a trade off really - you loose some functionality, for another kind of functionality. Only use it when it's needed. You'll notice that many good AJAX pages uses it discretely, without disturbing ordinary browsing.

broneah
March 14th, 2007, 10:24 AM
I didnt know ajax wasnt using asyncronistic javascript and xml technology. How do you expect a non java user to brows an ajax powered site?

Surrogate
March 15th, 2007, 09:35 PM
I didnt know ajax wasnt using asyncronistic javascript and xml technology. How do you expect a non java user to brows an ajax powered site?

Accessibility? Unobtrusive javascript? You can completely separate your document from your javascript, making it work absolutely 100% using the normal standards. And then put the AJAX layer above it using unobtrusive javascript. This way it will work for even those with computers from the stoneage.

No they won't see AJAX, but they'll see the same amount of information, albeit without all the effects. (Some on modern computers, with modern browsers actually prefer it this way)

In my humble opinion, a good ajax powered site works fine when the ajax layer is disabled. It's an enhancement, not a replacement - Unobtrusive and accessible.

Read about it here:
http://alistapart.com/articles/behavioralseparation

There's no reason a page should work any less, when either CSS or Javascript is disabled. Well, unless the creator is too lazy to ensure it of course, or the target audience is ensured to use the newest browsers.