站内搜索
分类列表
本类阅读排行
本类推荐文章
- ASP技巧:让Len,Left,Right函数识...
- 用ASP实现IE地址栏参数的判断
- 如何实现ASP.NET网站个性化
- 如何在Asp.net中使用HtmlArea编辑...
- 用ASP.Net实现在线压缩和解压缩
- ASP实现不存在的网页就自动发送邮...
- 用ASP取出HTML里面的图片地址的函...
- asp.net跳转页面的三种方法比较
- 一个Winsock组件
- 用WinSock设计Chat程序(转)
- 在MFC应用中深入定制WebBrowser控...
- 这几天有人问关于编应.dll的问题,...
- 在Visual J++中编写ASP COM组件(转...
- 一个显示Grid的VBScript对象
- 好东西,快来看呀:(转载自中华网...
广告
请看被打开的子窗口继承父窗口定义的styleSheets的例子
作者: 来源: 点击: 日期:2007-4-10 23:38:33
test.htm
<html>
<head>
<title>test</title>
<style type=text/css id=fatherStyle>
body {background:#efefef}
.s1 {background: red}
</style>
</head>
<body>
<input type=button value=open onclick=window.open('son.htm','')>
</body>
</html>
------------------------------------------
son.htm
<HTML>
<HEAD><TITLE></TITLE>
<style type=text/css id=sonStyle>
</style>
<script>
bgd=opener.document.styleSheets(0).rules(1).style.background;
name=opener.document.styleSheets(0).rules(1).selectorText;
document.styleSheets.sonStyle.addRule(name,"background:"+bgd);
//以上几条语句使得本页面可以使用父窗口定义的s1,但是这很麻烦,有什么简单的办法可以继承父窗口定义的所有styleSheets吗?象下面的语句就出错:
//document.styleSheets.sonStyle.rules=opener.document.styleSheets.fatherStyle.rules;
function changeStyle(){
d1.className="s1";
}
</script>
</HEAD>
<BODY>
<span id=d1>测试文字</span><br>
<input type=button value=change onClick=changeStyle()>
</body>
</html>
<html>
<head>
<title>test</title>
<style type=text/css id=fatherStyle>
body {background:#efefef}
.s1 {background: red}
</style>
</head>
<body>
<input type=button value=open onclick=window.open('son.htm','')>
</body>
</html>
------------------------------------------
son.htm
<HTML>
<HEAD><TITLE></TITLE>
<style type=text/css id=sonStyle>
</style>
<script>
bgd=opener.document.styleSheets(0).rules(1).style.background;
name=opener.document.styleSheets(0).rules(1).selectorText;
document.styleSheets.sonStyle.addRule(name,"background:"+bgd);
//以上几条语句使得本页面可以使用父窗口定义的s1,但是这很麻烦,有什么简单的办法可以继承父窗口定义的所有styleSheets吗?象下面的语句就出错:
//document.styleSheets.sonStyle.rules=opener.document.styleSheets.fatherStyle.rules;
function changeStyle(){
d1.className="s1";
}
</script>
</HEAD>
<BODY>
<span id=d1>测试文字</span><br>
<input type=button value=change onClick=changeStyle()>
</body>
</html>
请看被打开的子窗口继承父窗口定义的styleSheets的例子 评论
