Of the following:
which one is the present standard? Which one to use for better browser compatibility?
Similarly, what are the recommendations for JavaScript and Ajax?
Edited:
I design my applications using Aptana Studio. How to know which version of HTML/JavaScript/Ajax it is using and how to change it?
For markup, I would suggest HTML 4 or XHTML 1.0/1.1. However, if you want to use XHTML 1.1, you have to deliver it as application/xml, which does not work under Internet Explorer and you can’t use some of the most used external tools that inject fragments on your page, like AdSense for example. HTML 5 is not fully supported by any browser, and there’s no official standard for it yet, so any support might change in future.
For scripting, use ECMAScript 3. ECMAScript 4 was abandoned, and ECMA Script 5 is not yet supported by most of the implementations our there.
For Ajax, stick with XMLHttpRequest Level 1. Level 2 is still a working draft and I am not sure which browsers have support for it.
Update: I don’t know how you can force Aptana to a particular (X)HTML version through its settings, but if you have access to the raw document, you can add the proper DTD (
<!DOCTYPE>) for the markup you want and Aptana should obey by it. THe DTDs for HTML 4.0 and XHTML 1.0 are as follow (pick only one):(I am sure that Aptana also has this as a choice somewhere in the dialogs/menus when you create a new document and it will add the proper DTD based on that choice.)
To choose the proper version of ECMAScript, just put your scripts into a non-versioned script tag (
<script type="text/javascript">– see note). This MIME type is associated with JavaScript 1.5/ECMAScript 3.As for the proper XMLHttpRequest, I would suggest (as others did in their answers) using jQuery or any other JavaScript framework (Dojo, Prototype and so on) to take care of doing the right thing on each browser. Aptana comes with most of these JavaScript frameworks out of the box, so you just have to choose the one you want to use. My personal preference is jQuery.
Note: according to IANA (RFC4329) the
text/javascriptMIME type on the<script>element is obsolete and should be replaced byapplication/javascriptorapplication/ecmascript. However, the latter are not supported by Internet Explorer.