1 在CSS中调用Javascript代码:
(主要原理是在CSS中通过设置背景对象的url属性来加入JS代码)
(主要原理是在CSS中通过设置背景对象的url属性来加入JS代码)
<style type="text/css">
body{
height:200px;
background:url(javascript:alert("上帝来了!blog.k99k.com"));
}
</style>
2 在Javascript中调用CSS:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
.red { background-color:red }
.blue { background-color:blue }
</style>
</head>
<body>
<div id="div1" class=blue width="100%" onclick="this.className='red'">
圣诞快乐!
</div>
</body>
</html>
浙公网安备 33010602011771号