通过button

<link id=m rel=stylesheet href="docEdit.css" type="text/css">
<input onclick="document.all.m.href='http://lucky.myrice.com/cssforv6/index.css'" value="change" type=button>

 

通过select

代码
<select onchange="document.styleSheets[0].href=this.options[this.selectedIndex].value+'.css'" id=select1 name=select1>
<option value="Style/new">默认风格</option>
<option value="Style/red">粉红风情</option>
<option value="Style/blue">蓝色港湾</option>
<option value="Style/black">灰暗忧郁</option>
</select>

 

 

代码
用过java的人都只到java中可以根据需要导入所需要的java类. 
javascript中我们也可以实现类似的功能从而减少引入js文件的量,将少网络传输. 

方法就是:document.write('
<script src="apppath/js/my.js">'); 

如果有很多js文件,我们可以按照类似于java的方式导入 

先写一个导入函数 
function importJ(fpath){ 
   fpath = fpath.replace(/\./g,
'\/'); 
   document.write('<script src="'+ basePath + fpath + '.js"></script>'); 


导入的时候就可以用以下代码: 
importJ(
'apppath.js.my'): 

 

 

相关文章:

  • 2022-12-23
  • 2021-12-21
  • 2021-06-23
  • 2022-12-23
  • 2021-12-26
  • 2021-12-26
  • 2021-05-31
  • 2021-05-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案