Cross-browser |
Cross-browser refers to the ability for a website, web application, HTML construct or client-side scripting to support multiple web browsers.
The term was widely used during the browser wars in late-90s. In that context, the term referred to websites and code snippets that worked in both Internet Explorer and Netscape Navigator. During the browser wars, new features were added to browsers without any coordination between vendors. Thus it often happened that though both browsers supported some particular feature, there were differences in the way the feature worked, ranging from slight cosmetic issues to profound conceptual differences.
The term is still in use (as of 2005), but to lesser extent. The main reasons for this are:
= Example of cross-browser coding =
To follow this example, you may need basic knowledge of HTML and JavaScript. Consider this snippet of HTML code:
<div id= sample style= position : absolute; top : 100px; left : 100px; >some text</div>
The code describes a block of text, which should be displayed 100 pixels from the top and to the left from the top-left corner of the browser window. In a Netscape Navigator 4 -series browser, you would move it right with the following JavaScript code:
document.layers[ sample ].left = 200;
However, to accomplish the same thing Internet Explorer 4 you need to do this:
document.all[ sample ].style.left = 200;
In order for the code to work in both browsers and thus be cross-browser compatible, it needs to written like this:
if (document.all) document.all[ sample ].style.left = 200; else if (document.layers) document.layers[ sample ].left = 200;
The following code that uses World Wide Web_Consortium standard Document Object Model method works in Mozilla browsers, recent versions of Internet Explorer and various other recent browsers that comply to the W3C standard:
document.getElementById( sample ).style.left = 200px ;
= External links =
|
|