01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | < head >< title >我是 title</ title > < script > function myBrowser(){ var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 var isOpera = userAgent.indexOf("Opera") > -1; if (isOpera) { return "Opera" }; //判断是否Opera浏览器 if (userAgent.indexOf("Firefox") > -1) { return "FF"; } //判断是否Firefox浏览器 if (userAgent.indexOf("Chrome") > -1){ return "Chrome"; } if (userAgent.indexOf("Safari") > -1) { return "Safari"; } //判断是否Safari浏览器 if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) { return "IE"; }; //判断是否IE浏览器 } var mb = myBrowser(); var chengfa = 1; if("Safari" == mb){ chengfa = 1; } if("Safari" != mb){ if(window.orientation == undefined){ document.write("< meta id=\"viewp1\" name=\"viewport\" content=\" width = 1400px , minimum-scale = 0 .1, maximum-scale = 2 .0, initial-scale = "+(window.screen.width * 8/(chengfa * 12600))+" \">"); }else if(window.orientation == 0 || window.orientation == 180){ document.write("< meta id=\"viewp1\" name=\"viewport\" content=\" width = 1400px , minimum-scale = 0 .1, maximum-scale = 2 .0, initial-scale = "+(window.screen.width * 4/(chengfa * 12600))+" \">"); }else if(window.orientation == 90 || window.orientation == (-90)){ document.write("< meta id=\"viewp1\" name=\"viewport\" content=\" width = 1400px , minimum-scale = 0 .1, maximum-scale = 2 .0, initial-scale = "+(window.screen.height * 4/(chengfa * 12600))+" \">"); } var viewp1 = document.getElementById('viewp1'); function changeViewp1(){ if(window.orientation == 0 || window.orientation == 180){ viewp1.setAttribute('content','width=1400px, minimum-scale=0.1,maximum-scale=2.0, initial-scale='+ (window.screen.width * 4/(chengfa * 12600))); }else if(window.orientation == 90 || window.orientation == (-90)){ viewp1.setAttribute('content','width=1400px, minimum-scale=0.1,maximum-scale=2.0, initial-scale='+ (window.screen.height * 4/(chengfa * 12600))); } } changeViewp1(); if("Safari" == mb){ window.addEventListener("orientationchange",changeViewp1,false); } if(window.addEventListener){ window.addEventListener("resize",changeViewp1,false); }else if(window.attachEvent){ window.attachEvent("onresize",changeViewp1); } } </ script > </ head > |