//StyleSheet Object
function StyleSheet(doc){
this.sso = null;
this.doc = doc;
this.createStyleSheet();
}
StyleSheet.prototype.createStyleSheet = function (){
//IE
if(this.doc.createStyleSheet)
this.sso = this.doc.createStyleSheet();
else{//FF
var styles = this.doc.getElementsByTagName("HEAD")[0].getElementsByTagName("style");
if(styles.length > 0)
this.sso = styles[styles.length-1];
else{
try{
this.sso=this.doc.createElement("STYLE");
this.sso.type="text/css";
this.doc.getElementsByTagName("HEAD")[0].appendChild(this.sso);
}catch(e){
this.sso = null;
}
}
}
}
StyleSheet.prototype.insertRule = function (selector,cssText){
if(this.sso.addRule)
this.sso.addRule(selector,cssText,this.sso.rules.length);
else if(this.sso.sheet)
this.sso.sheet.insertRule(selector + "{" + cssText + "}",this.sso.sheet.cssRules.length);
}
var ss = new StyleSheet(document);
ss.insertRule("#comfrm"+ this.unique,cssText);
function StyleSheet(doc){
this.sso = null;
this.doc = doc;
this.createStyleSheet();
}
StyleSheet.prototype.createStyleSheet = function (){
//IE
if(this.doc.createStyleSheet)
this.sso = this.doc.createStyleSheet();
else{//FF
var styles = this.doc.getElementsByTagName("HEAD")[0].getElementsByTagName("style");
if(styles.length > 0)
this.sso = styles[styles.length-1];
else{
try{
this.sso=this.doc.createElement("STYLE");
this.sso.type="text/css";
this.doc.getElementsByTagName("HEAD")[0].appendChild(this.sso);
}catch(e){
this.sso = null;
}
}
}
}
StyleSheet.prototype.insertRule = function (selector,cssText){
if(this.sso.addRule)
this.sso.addRule(selector,cssText,this.sso.rules.length);
else if(this.sso.sheet)
this.sso.sheet.insertRule(selector + "{" + cssText + "}",this.sso.sheet.cssRules.length);
}
var ss = new StyleSheet(document);
ss.insertRule("#comfrm"+ this.unique,cssText);
解决方案 »
- 前辈们可否推荐一些Javascript入门书籍?
- 关于正则替换的一个问题
- JS取值娶不到,求教高手~
- mzTreeview空节点图标问题
- 我向在<head></head>中用javascript动态增加一行<link ...>
- js中如何把selected传递到option上
- JavaScript实现的页面右键菜单,现在只能在IE运行,请高手修改兼容到其他的浏览器,感激不尽。
- jquery mobile dialog 页面之间值传递
- 请JS中 innerHTML是干什么
- 使用window.open()弹出新窗口,使用IE时只会在新标签页打开。
- 同时打开多个窗口,如何判断鼠标当前处于哪个窗口位置?
- 请教:选项卡
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="样式.aspx.cs" Inherits="样式" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.table
{
background:#59CBF5
}
</style>
<script type="text/javascript">
function change()
{
var aa = document.getElementById("text").className="table";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="text" onclick="change()"><tr><td>请点击</td></tr></table>
</div>
</form>
</body>
</html>