现在的位置: 首页 > 综合 > 正文

js判断选择不同的样式文件

2018年06月07日 ⁄ 综合 ⁄ 共 1365字 ⁄ 字号 评论关闭
<script type="text/javascript">
	<!--分辨率1920-->
	var node0 = document.createElement('link');
	node0.rel = 'stylesheet';
	node0.href = 'css/sch.css';
	<!--分辨率1680-->
	var node1 = document.createElement('link');
	node1.rel = 'stylesheet';
	node1.href = 'css/sch1.css';
	<!--分辨率1440-->
	var node2 = document.createElement('link');
	node2.rel = 'stylesheet';
	node2.href = 'css/sch2.css';
	<!--分辨率1366-->
	var node3 = document.createElement('link');
	node3.rel = 'stylesheet';
	node3.href = 'css/sch3.css';
	<!--分辨率1280-->
	var node4 = document.createElement('link');
	node4.rel = 'stylesheet';
	node4.href = 'css/sch4.css';
	<!--分辨率1024-->
	var node5 = document.createElement('link');
	node5.rel = 'stylesheet';
	node5.href = 'css/sch5.css';
	if(window.screen.width>=1900&&window.screen.width<=2000){  
	 document.getElementsByTagName('head')[0].appendChild(node0);  
	}  
	if(window.screen.width>=1600&&window.screen.width<=1900){  
	 document.getElementsByTagName('head')[0].appendChild(node1);  
	}  
	if(window.screen.width>=1400&&window.screen.width<=1600 ){  
	 document.getElementsByTagName('head')[0].appendChildS(node2);
	}  
	if(window.screen.width>=1300&&window.screen.width<=1400 ){  
	 document.getElementsByTagName('head')[0].appendChild(node3); 
	}  
	if(window.screen.width>=1200&&window.screen.width<=1300 ){  
	 document.getElementsByTagName('head')[0].appendChild(node4); 
	} 
	if(window.screen.width>=1000&&window.screen.width<=1200 ){  
	 document.getElementsByTagName('head')[0].appendChild(node5); 
	} 
</script>

【上篇】
【下篇】

抱歉!评论已关闭.