使用document.selection 简单判断浏览器是否为ie核心

    技术2022-05-20  54

    使用document.selection 简单判断浏览器是否为ie核心

    今天学习php中的ubb代码,看源码看到了关于判断浏览器是否为ie核心的做法,感觉很简单,总结一下

    主要是利用document.selection,具体原因是这样的

    ie支持document.selection

    FireFox 支持window.getSelection()

    document.selection 只有ie支持,window.getSelection也只有FireFox和Safiri支持,都不是标准的语法

    alert(document.selection);//在ie核心下显示为object类型,而在非ie下为undefined if(document.selection){//这个代码可以作为简单的判断浏览器核心的 alert('IE核心的浏览器'); }else{ alert('非IE核心的浏览器'); }


    最新回复(0)