Ricjustsaid
11-22-2007, 11:59 PM
Hey, I'm new to WHT and just have a question about AJAX. Right now my site has absolutely no AJAX stuff on it, but I'm working on redesigning it and want to add some AJAX functions to it. But at the same time I really don't want to make my site unusable for people without JavaScript/AJAX support, so I want everything that uses AJAX to be backwards-compatible with non-JS browsers.
How do you guys do it? I'm rewriting my scripts (poll, gallery, contact forms, etc) to use OO and was just looking for some tips. Thanks! :)
Steve_Arm
11-23-2007, 02:24 AM
The percentage of people not using js is small that you only need to care for minor things. One tip is for your <a> tags is apply the link as usual and if there is a function attached to it make it return false. That way whoever doesn't have js will follow the link, otheres will get the function.
isurus
11-23-2007, 04:24 AM
That's good that you are making sure that everything works for non-JS users - it completely undermines a site's credibility (IMHO) when it doesn't degrade gracefully.
You can use JS to display the JS bits and hide the non-JS versions, see the code I posted here for an example:
http://www.webhostingtalk.com/showpost.php?p=4740102&postcount=14
You may want to check that all of the functionality that you require is available before displaying the JS bits - my example just checks that JS is enabled.
Let me know if anything needs clarification.
unity100
11-23-2007, 05:11 AM
people without js is not your only concern with ajax.
javascript, activex controls are stuff that can tax a browser, and subsequently computer.
most often i experience lock-ups and wait times just due to some code put in some 'hip' wannabee sites to go with the 2.0 hype.
accessibility comes on top. if people are turned down with the issues something is creating, there is no point in putting any nifty function on something.
additionally many security software have a negative outlook against many ajax components, for they are known for being overused to propagate viruses and trojans and hacks.
Ricjustsaid
11-23-2007, 06:30 PM
That's good that you are making sure that everything works for non-JS users - it completely undermines a site's credibility (IMHO) when it doesn't degrade gracefully.
You can use JS to display the JS bits and hide the non-JS versions, see the code I posted here for an example:
[snip]
You may want to check that all of the functionality that you require is available before displaying the JS bits - my example just checks that JS is enabled.
Let me know if anything needs clarification.
Right! Not only that, but I'd still like the content to be accessible by search engine spiders, mobile browsers and paranoid people like me who have a browser that supports JS but browse with it disabled until we trust the site (NoScript is awesome). :P What really annoys me is the website that relies on JS for EVERYTHING including the navigation, forcing the user to turn on JS. :o
I'll have to check out that example -- thanks for the link!
most often i experience lock-ups and wait times just due to some code put in some 'hip' wannabee sites to go with the 2.0 hype.
accessibility comes on top. if people are turned down with the issues something is creating, there is no point in putting any nifty function on something.
additionally many security software have a negative outlook against many ajax components, for they are known for being overused to propagate viruses and trojans and hacks.
Maybe from an over-use of JS? I definitely wouldn't want my site to totally rely on it, but some neat features might benefit a site. Like for example I have an autocomplete function which tries to help the user find what they're looking for while searching a database. It's not needed, but it makes searching easier.
I'm kind of worried about the security problems you've mentioned. I always filter the input from users by escaping it, stripping out characters that could be dangerous, and turning HTML characters into harmless entities... is that enough?