Since the emergence of CSS, some vendors have hoped that CSS can be more flexible. The earliest concept of CSS dynamic is embodied in "dynamic expressions" (or dynamic attributes, dynamic attribute, the concept of dynamic expressions may be derived from the following scenarios:
- The size or position of the element is calculated by the browser or HTML document.
- Use a variable as the value of the style attribute, such as the frequently used color. Use a global variable.
Netscape, the originator of the browser, and IE, both tried to use JavaScript in CSS. Netscape proposed JSS technology a long time ago. Of course, it only supports Netscape browsers:
"JavaScript style sheets. In the beginning, they were jass (JavaScript accessible style sheets), then jsss or JSS (JavaScript style sheets), and nowNetscape has taken to calling them style sheets with JavaScript syntax. They exist in the Netscape DHTML documentation, a few books, and a couple of old third party articles on the web. the best introduction to JSS is by HTML veteran Chuck musciano, at sunworld. A concise, clear examination, this article was written a year ago (Limit l 1997 ). next to nothing has been written on the Web since then."
JSS of a classic Netscape BrowserCodeAs follows:
<Style type = 'text/JavaScript '>
With (parent.frames.main.doc ument. classes. Items. span) {
Width = menuwidth;
Color = fntcol;
Fontsize = fntsiz;
Fontweight = fntwgh;
Fontstyle = fntsty;
Fontfamily = fntfam;
Borderwidth = borwid;
Bordercolor = borcol;
Borderstyle = borsty;
Lineheight = linhgt;
}
</Style>
Is it weird? You do not need to doubt that this is indeed the invention of Netscape, the originator of the browser. As the competition with IE fails, the Netscape Browser gradually exits from the stage of history. Correspondingly, the JSS technology has been extinct in the world. The following address gives a detailed introduction of JSS: http://www.webreference.com/dhtml/column18/menuFrJSS.html Microsoft after ie5 proposed "Dynamic Properties" technology: "Ie5 and later versions support the use of expressions in CSS to associate CSS attributes with javas alias expressions. the CSS attributes here can be inherent attributes of elements, it can also be a custom attribute. That is to say, the CSS attribute can be followed by a javas alias expression. The value of the CSS attribute is equal to the result calculated by the javas alias expression. You can directly reference attributes and methods of an element in an expression, or use other browser objects. This expression is like a member function in this element. " A classic CSS Expression Code is as follows: # Mydiv
{
Position : Absolute ;
Width : 100px ;
Height : 100px ;
Left : Expression (document. Body. offsetwidth-110 + "PX ") ;
Top : Expression (document. Body. offsetheight-110 + "PX ") ;
Background : Red ;
} The emergence of dynamic expressions of IE has caused a lot of web developers. However, after a short time, its despicable performance began to cause criticism. It is said that, dynamic expressions were executed tens of thousands of times when the Dom was updated. In addition, due to incompatibility with web standards, CSS expressions have almost been abandoned by web developers who are increasingly pursuing the trend. In the end, IE8 claims that it no longer supports dynamic expressions (Dynamic dynamic properties or CSS expressions) in its standard mode. For more information about dynamic expressions (dynamic properties or CSS expressions, see: http://msdn.microsoft.com/en-us/library/ms537634 (vs.85 ). so far, the giants of the two browsers have terminated the idea of using JavaScript in CSS. However, the demise of CSS-mixed Javascript is only the victim of the browser war and competition between custom standards and W3C standards. From the above historical facts, using JavaScript in CSS seems to have proved to be a promising path. Program Members began to shift the focus of dynamic CSS research to one of the core CSS-"selector", that is, "Implementing selector that is not yet feasible through javascript, the most famous is the English Dean Edwards (Dean Edwards, personal homepage: http://dean.edwards.name/) "ie7.js" where a personal website server is placed in the kitchen, "ie7.js" has implemented W3C css3 standards in advance. Of course, its functions are not limited to this. Many people are still studying how to use JavaScript in CSS or use JavaScript to extend the existing CSS functions, such as the elder brother: sheet (JavaScript style sheets ). Why are some enthusiastic programmers so happy with JavaScript-based CSS? I think there are two main reasons:
- 1. Static Characteristics of CSS
- 2. the W3C standards and browser versions cannot and will never be synchronized
- 3. the expectations of HTML developers and W3C standards cannot and cannot be synchronized
The shortcomings of the html css technology have attracted the attention of Software Development giants. In the currently arrogant Application Markup Language, such as Microsoft's XAML or Adobe's mxml, its CSS can be defined not only dynamically, but also attributes, content, and events. Maybe, a few years later, we will see W3C preparing to revise the new CSS standard to make it more dynamic.