> Does anyone have a preferred way for handling browsers that are not > officially supported by jQuery, such as Netscape? What I am planning > on doing is having server-side browser detection code which gives me > the browser name, platform, and version number, then in my site, > having each page coded in two different ways: one for Ajax and one > without Ajax. Is this what other people do?
Server-side browser detection is unreliable due to User Agent spoofing. It's much better to just code your pages so that the JavaScript features are tacked on transparently, and have a usable alternative when JavaScript is turned off. That way, you can treat any broken browser as one which does not support JavaScript. You can use several tricks to do this in a relatively seamless way: 1) Define a global variable "jsEnabled" or something, which checks for required DOM functions. For example: var jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById; Then, you can augment this with browser-specific denials if there are still problems. 2) In the global scope (NOT in .ready()), you set a class on the <html> element: if (jsEnabled) { document.documentElement.className = 'js'; } 3) Then, you define a bunch of CSS rules with the ancestor selector "html.js" (e.g. "html.js #myelement") where you apply the required styles for JavaScript-based features. This can include hiding collapsed section of the page, making Ajax widgets visible, etc. 4) Any additional changes that need to be made to the source document are done in $(document).ready(), but also only if (jsEnabled) is true. This gives you the best of both worlds: you avoid non-JavaScript users seeing useless widgets on the page or having inaccessible content, while JavaScript users don't see the page change drastically as soon as it finished loading. Remember: even with $(document).ready () there is the possibility of incremental rendering. Then, when you tell your users to turn on JavaScript or switch browsers, it's not an ultimatum: it's a choice for them, if they want a better user experience, but they can't still see and use your site. Steven Wittens _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/