通过改变外嵌CSS样式文件即时改变网页样式

来源:互联网 发布:js获取扫描枪按键事件 编辑:程序博客网 时间:2024/05/29 18:27

下例通过改变外嵌CSS样式文件即时改变网页样式:

在<head>....</head>之间放置以下内容:

<link href="css/style01.css" rel="stylesheet" type="text/css" id="cssStyle" >

<script type="text/javascript">
  function mm_changeStyle(file){
   document.getElementById("cssStyle").setAttribute("href",file);
}
</script>



以下内容置于<body>....</body>之间:

<img src="img/changeStylebt.gif" alt="" width="101" height="42" usemap="#Map" border="0"/>

<map name="Map" id="Map">
  <area shape="rect" coords="39,15,50,27"
   href="Javascript:mm_changeStyle('css/style01.css');" />
  <area shape="rect" coords="56,15,68,26"
   href="Javascript:mm_changeStyle('css/style02.css');" />
  <area shape="rect" coords="73,15,84,27"
   href="Javascript:mm_changeStyle('css/style03.css');"/>
</map>
原创粉丝点击