From DHTML to DOM Scripting
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Common DHTML scripts have several issues:
- Browser and version dependence: A common way to test whether the script can be exe-cuted was to read out the browser name in the navigator object. As a lot of these scripts were created when Netscape 4 and Internet Explorer 5 were state-of-the-art, they fail to support newer browsers--the reason being browser detection that doesn't take newer versions into account and just tests for versions 4 or 5.
- Code forking: As different browsers supported different DOMs, a lot of code needed to be duplicated and several browser quirks avoided. This also made it difficult to write modular code.
- Markup dependence: Instead of generating or accessing HTML via the DOM, a lot of scripts wrote out content via the document.write directive and added to each document body instead of keeping everything in a separate--cached--document. All of these stand in a stark contrast to the requirements we currently have to fulfill:
- Code should be cheap to maintain and possible to reuse in several projects.
- Legal requirements like the Digital Discrimination Act (DDA) in the UK and Section 508 in the US strongly advise against or in some cases even forbid web products to be depen-dent on scripting.
- More browsers, user agents (UAs) on devices such as mobile phones, or assistive tech-nology helping disabled users to take part in the Web make it impossible to keep our scripts dependent on browser identification.
- Newer marketing strategies make it a requirement to change the look and feel of a web site or a web application quickly and without high cost--possibly even by a content management system.
Figure 3-1. The different layers of web development
- The presentation layer: Is displayed on the client and is the look of the web page (CSS, imagery).
- The structure layer: Is converted or displayed by the user agent. This is the markup defining what a certain text or media is (XHTML).
- The content layer: Is stored on the server and consists of all the text, images, and multimedia content that are used on the site (XML, database, media assets).
- The business logic layer (or back end): Runs on the server and determines what is done with incoming data and what gets returned to the user.