<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-Type "content =" text/html; charset = UTF-8 "/> <title> dimming div: drag the prompt window </title> </pead> <body> <input type =" button "value =" Click here "onclick =" alertWin ('title ', 'Here is the content', 300,200); "/> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
IE7.0, Firefox2.0, and Opera9.0 passed the test.
Thank you for your comments.
I have been researching Js for some time ago. I have a lot of articles on browser compatibility on the Internet. I have found several articles for you:
Http://blog.csdn.net/zqian1987/archive/2008/03/02/2140055.aspx
Http://www.cnblogs.com/jacklong/archive/2008/01/10/1033954.html
I will write some of my experiences during this time. I will mainly introduce compatibility with IE and FireFox. The Versions earlier than Opera9.0 seem to be not supported by N or so, versions later than Opera9.0 are similar to FireFox in Javascript interpretation.
I am introducing some details, focusing on writing some uncommon situations. I will continue to add the following when I think of new ones:
1. Create an Element, which is commonly written as createElement ("div ")
In IE, you can also write createElement ("<div style = 'color: # ffff'>"), but Firefox does not recognize
2. The concepts of width and height in IE are different from those in Firefox. width in IE = width + 2 * borderWidth + 2 * Padding in FireFox
See http://help.powereasy.net/Template/WEB/1557.html
3. dynamically add css code
CssStr = "p {color: # FF0000;} a {font-size: 9pt ;}";
Var style = win.doc ument. createStyleSheet ();
Style.css Text = cssStr; FireFox: copy the content to the clipboard code:
CssStr = "p {color: # FF0000;} a {font-size: 9pt ;}";
Var style = win.doc ument. createElement ("style ");
Style. type = "text/css ";
Style. innerHTML = cssStr;
Win.doc ument. getElementsByTagName ("HEAD "). item (0 ). appendChild (style); 4. Add rows or columns to the table. General Syntax: insertRow (-1), insertCell (-1)
In IE, you can write insertRow () or insertCell (). Firefox does not recognize this.
5. alert () in the warning dialog box. If no parameter is set during writing in IE, the default parameter is an empty string. In Firefox, a parameter is required. If null is set, the parameter is written as alert ("");
6. element. style. width values must be written as 24px. If only the number is 24, FireFox will not recognize the values. IE Can
7. When using the Element, bind it with events such as onclick, onmouseover, onmousedown, and onmouseout.
Element. onclick = function () {alert ("hello kitty ");};
Pay attention
AppendChild is used to add this element to the upper-level element. innerHTML cannot be used in the upper-level element, which will invalidate the event.