}
else {
 ">

使用脚本替换CSS

80酷酷网    80kuku.com

  css|脚本判断客户端浏览器载入样式表
if (browser.isNS4x == true) {
 document.write('<link rel="stylesheet" type="text/css" href="ns4.css">');
}
else {
 document.write('<link rel="stylesheet" type="text/css" href="advanced.css">');
}
判断客户端浏览器控制页面样式
if (browser.isNS4x == true) {
 
 // Tag selectors
 document.tags.body.fontSize = '11px';
 document.tags.td.fontSize = '11px';
 document.tags.th.fontSize = '11px';
 document.tags.p.fontSize = '11px';
 
 // Class selectors
 document.classes.someClass.all.fontSize = '11px';
 
 // Id selectors
 document.ids.someId.fontSize = '11px';
}
Using the DOM
The best way to work with from Javascript is to use the DOM. You can disable or remove existing stylesheets, add new stylesheets, make existing <link> tags point to different .css files, add or remove rules, add or remove declarations, change classes or styles on existing elements, whatever you like. But there is a catch: the browsers you want to manipulate styles for must support the DOM methods needed to do the manipulation you want. So instead of doing browser detection, it would be better to do object detection on the DOM objects you want to manipulate. The DOM is a huge topic and I'm not going to tackle it here. Instead, I direct readers to an article on Manipulating using the W3C DOM and Peter-Paul Koch's DOM Compatibility Chart for .

Referrence
filtering using Javascript

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: