javascript判斷瀏覽器 和 完美相容IE和chrome的對聯廣告。

來源:互聯網
上載者:User
//判斷瀏覽器 //----------------------------- 判斷瀏覽器 -------------------------var userAgent = navigator.userAgent; //取得瀏覽器的userAgent字串var isOpera = userAgent.indexOf("Opera") > -1; //判斷是否Operavar isMaxthon = userAgent.indexOf("Maxthon") > -1 ; //判斷是否傲遊3.0var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera ; //判斷是否IE var isFF = userAgent.indexOf("Firefox") > -1 ; //判斷是否Firefoxvar isFireffox=isFFvar isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") < 1 ; //判斷是否Safarivar isChrome = userAgent.indexOf("Chrome") > -1 ; //判斷是否Chromefunction myBrowser(){if(isIE){    var IE5 = IE55 = IE6 = IE7 = IE8 = false;   var reIE = new RegExp("MSIE (\\d+\\.\\d+);");   reIE.test(userAgent);   var fIEVersion = parseFloat(RegExp["$1"]);    IE55 = fIEVersion == 5.5 ;   IE6 = fIEVersion == 6.0 ;   IE7 = fIEVersion == 7.0 ;   IE8 = fIEVersion == 8.0 ;    if(IE55){ return "IE55"; }   if(IE6){ return "IE6"; }   if(IE7){ return "IE7"; }   if(IE8){ return "IE8"; }} if(isFF){ return "FF"; }if(isOpera){ return "Opera"; }if(isMaxthon){ return "Maxthon"; }if(isSafari){ return "Safari"; }if(isChrome){ return "Chrome"; } } //myBrowser() end  //window.onload=function(){//document.getElementById("ua").innerHTML=navigator.userAgent;//if(myBrowser()=="FF"){alert("我是 Firefox");}//if(myBrowser()=="Maxthon"){alert("我是傲遊(webkit核心)");}//if(myBrowser()=="Opera"){alert("我是 Opera");}//if(myBrowser()=="Safari"){alert("我是 Safari");}//if(myBrowser()=="Chrome"){alert("我是 Chrome");}//if(myBrowser().indexOf("IE")>-1){alert("我是 IE");} //if(myBrowser()=="IE55"){alert("我是 IE5.5");}//if(myBrowser()=="IE6"){alert("我是 IE6");}//if(myBrowser()=="IE7"){alert("我是 IE7");}//if(myBrowser()=="IE8"){alert("我是 IE8");}////} function iif(a,b,c){if(a){return b}else{return c;1}}  var jishu1=0;function rightbottomad(cid){jishu1++;var abc = document.getElementById(cid);var top = document.documentElement.scrollTop+document.documentElement.clientHeight-80-560+"px";//20是這個層的高度;abc.style.top=iif(isIE,top,"270px")if (isIE){setTimeout(function(){rightbottomad(cid);},50);}return abc.style.top;}function closediv(){document.getElementById('tuad').style.visibility='hidden';}var position=iif(isIE,"absolute","fixed"); document.write('<div id="tuad" style="position:'+position+';right:0;"><a href="/" ><img src="/pic/求片報錯有獎.gif" /></a></div>');document.write('<div id="tuad1" style="position:'+position+';left:0;"><a href="/" ><img src="/pic/求片報錯有獎.gif" /></a></div>');rightbottomad('tuad');rightbottomad('tuad1'); // 網頁特效 document  好東西。不過有效小遺憾的。我修改了。然後用在了 對聯廣告上。。。完美 相容IE和 Chrome
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.