JavaScript浏览器编程之——使用URL传递参数

  default.css:
body {
    background-color:#F0FFF0;
}

  blue.css:

body {
    background-color:blue;
}
  red.css:
body {
    background-color:red;
}

 

  white.css:
body {
    background-color:white;
}

 

  ex9.html:
ExpandedBlockStart.gif 代码
 1  < html >
 2  < head >
 3  < title > URL参数传递 </ title >
 4  < style  type ="text/css" >
 5      *  { margin : 0 }
 6      body  { text-align : center ; min-width : 760px }
 7      div  { padding : 3px 3px 3px 3xp }
 8      #main  { width : 360px ; margin : 0 auto ; text-align : left ; margin-top : 30px }
 9  </ style >
10 
11  < script  type ="text/javascript" >
12       //  URL参数
13       var  search  =  document.location.search;
14       if ( ! search  &&  search.length  ==   0 ) {
15          search  =   " default " ;
16      }  else  {
17          search  =  search.substring( 1 ,search.length);
18      }
19       //  动态加载样式表
20       var  style  =   " <link href=' "   +  search  +   " .css' rel='stylesheet' /> " ;
21      document.write(style);
22  </ script >
23  </ head >
24  < body >
25       < div  id ="main" >
26           < div >< href ="ex9.html" > 默认 </ a ></ div >
27           < div >< href ="ex9.html?blue" > 蓝色 </ a ></ div >
28           < div >< href ="ex9.html?red" > 红色 </ a ></ div >
29           < div >< href ="ex9.html?white" > 白色 </ a ></ div >
30       </ div >
31  </ body >
32  </ html >

 

转载于:https://www.cnblogs.com/mikelin/archive/2010/02/03/1662505.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值