• 关于各个浏览器的兼容问题


    1.ie7中a标签的宽高与其父元素li不一样(现在浏览器中宽高是默认一样的)

    方法:给a标签设置固定的宽、高

    2.ie6以下对除了a之外的元素的hover不起作用等兼容问题

    方法:

     body{
            behavior:url(csshover.htc);//引入该文件
          }
    //csshover.htc源代码
    <attach event="ondocumentready" handler="parseStylesheets"/> 
    <script language="JScript"> 
    var currentSheet, doc = window.document, activators = { 
    onhover:{on:'onmouseover', off:'onmouseout'}, 
    onactive:{on:'onmousedown', off:'onmouseup'} 
    }; 
    function parseStylesheets(){ 
    var sheets = doc.styleSheets, l = sheets.length; 
    for(var i = 0; i < l; i++){ 
    parseStylesheet(sheets[i]); 
    }; 
    }; 
    function parseStylesheet(sheet){ 
    if(sheet.imports){ 
    try{ 
    var imports = sheet.imports, l = imports.length; 
    for(var i = 0; i < l; i++){ 
    parseStylesheet(sheet.imports[i]); 
    }; 
    }catch(securityException){}; 
    }; 
    try{ 
    var rules = (currentSheet = sheet).rules, l = rules.length; 
    for(var j = 0; j < l; j++){ 
    parseCSSRule(rules[j]); 
    }; 
    }catch(securityException){}; 
    }; 
    function parseCSSRule(rule){ 
    var select = rule.selectorText, style = rule.style.cssText; 
    if(!(/(^|s)(([^a]([^ ]+)?)|(a([^#.][^ ]+)+)):(hover|active)/i).test(select) || !style) return; 
    var pseudo = select.replace(/[^:]+:([a-z-]+).*/i, 'on$1'); 
    var newSelect = select.replace(/(.([a-z0-9_-]+):[a-z]+)|(:[a-z]+)/gi, '.$2' + pseudo); 
    var className = (/.([a-z0-9_-]*on(hover|active))/i).exec(newSelect)[1]; 
    var affected = select.replace(/:hover.*$/, ''); 
    var elements = getElementsBySelect(affected); 
    currentSheet.addRule(newSelect, style); 
    for(var i = 0; i < elements.length; i++){ 
    new HoverElement(elements[i], className, activators[pseudo]); 
    }; 
    }; 
    function HoverElement(node, className, events){ 
    if(!node.hovers) node.hovers = {}; 
    if(node.hovers[className]) return; 
    node.hovers[className] = true; 
    node.attachEvent(events.on, function(){ 
    node.className += ' ' + className; 
    }); 
    node.attachEvent(events.off, function(){ 
    node.className = node.className.replace(new RegExp('\s+'+className, 'g'),''); 
    }); 
    }; 
    function getElementsBySelect(rule){ 
    var parts, nodes = [doc]; 
    parts = rule.split(' '); 
    for(var i = 0; i < parts.length; i++){ 
    nodes = getSelectedNodes(parts[i], nodes); 
    }; 
    return nodes; 
    }; 
    function getSelectedNodes(select, elements){ 
    var result, node, nodes = []; 
    var classname = (/.([a-z0-9_-]+)/i).exec(select); 
    var identify = (/#([a-z0-9_-]+)/i).exec(select); 
    var tagName = select.replace(/(.|#|:)[a-z0-9_-]+/i, ''); 
    for(var i = 0; i < elements.length; i++){ 
    result = tagName ? elements[i].all.tags(tagName) : elements[i].all; 
    for(var j = 0; j < result.length; j++){ 
    node = result[j]; 
    if((identify && node.id != identify[1]) || (classname && !(new RegExp('\b' + classname[1] + '\b').exec(node.className)))) continue; 
    nodes[nodes.length] = node; 
    }; 
    }; 
    return nodes; 
    }; 
    </script> 

    3.检测ie6版本

    //js兼容ie6
    window.onload=function(){
        //判断是否为IE浏览器
        var isIE=!!window.ActiveXObject;
        var isIE6=isIE&&!window.XMLHttpRequest;
    }
    //Jquery兼容IE6
    $(function(){
        if($.browser.msie&&$.browser.version.substr(0,1)<7){
    
        }
       //高版本的jquery检验ie6
       $.support.leadingWhitespace
    })

    4.

  • 相关阅读:
    Daily Scrumming* 2015.12.19(Day 11)
    Daily Scrumming* 2015.12.18(Day 10)
    软件工程 个人作业1
    网络1711-12&信管1711-12 图 作业评分
    网络1711-12 数据结构第一次作业评分
    Java课程设计
    网络1711-1712班 c 语言评分总表一览
    网络1711班 C语言第八次作业批改总结
    201621123050 《Java程序设计》第14周学习总结
    201621123050 《Java程序设计》第13周学习总结
  • 原文地址:https://www.cnblogs.com/luxiaoxiao/p/6589637.html
Copyright © 2020-2023  润新知