发布于 2016-09-14 08:27:09 | 121 次阅读 | 评论: 0 | 来源: 网友投递
这里有新鲜出炉的Javascript教程,程序狗速度看过来!
JavaScript客户端脚本语言
Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。
请注意代码和传统的DHTML的区别。在DHTML你通过直接修改页面上的特定元素来改变样式,而这里的代码修改的是样式表。
在这里查看W3C DOM-CSS的兼容性列表。
定义
一个页面总是包含一个或者几个样式表,一个样式表里面包含一条或者几条规则,一条规则里有详细的样式声明。这个页面的样式表如下:
<link rel="stylesheet" href="../quirksmode.css">
<style>
<!--
@import url("test.css");
p,h2,h3 {
padding-right: 10px;
}
pre.test + * {
margin-right: 20%;
}
pre.test {
background-color: #ffffff;
}
-->
</style>
var theRules = new Array();
if (document.styleSheets[1].cssRules)
theRules = document.styleSheets[1].cssRules
else if (document.styleSheets[1].rules)
theRules = document.styleSheets[1].rules
@import url("test.css");
p,h2,h3 {
padding-right: 10px;
}
pre.test + * {
margin-right: 20%;
}
pre.test {
background-color: #ffffff;
}
rule.style.color = '#0000cc';
rule.style.setProperty('color','#00cc00',null);
function changeIt() {
if (!document.styleSheets) return;
var theRules = new Array();
if (document.styleSheets[1].cssRules)
theRules = document.styleSheets[1].cssRules
else if (document.styleSheets[1].rules)
theRules = document.styleSheets[1].rules
else return;
theRules[theRules.length-1].style.backgroundColor = '#EEF0F5';
}