87,915
社区成员
发帖
与我相关
我的任务
分享
var browser = new (function () {
this.Opera = window.opera ? true : false;
this.IE = document.all && !this.Opera ? true : false;
this.IE6 = this.IE && typeof(window.XMLHttpRequest) == "undefined" ? true : false;
this.IE8 = this.IE && typeof(document.querySelectorAll) != "undefined" ? true : false;
this.IE7 = this.IE && ! this.IE6 && !this.IE8 ? true : false;
this.WebKit = /WebKit/i.test(navigator.userAgent) ? true : false,
this.iPhone = /iPhone|iPod/i.test(navigator.userAgent)? true : false;
this.Chrome = /Chrome/i.test(navigator.userAgent) ? true : false;
this.Safari = /Safari/i.test(navigator.userAgent) && !this.Chrome ? true : false;
this.Konqueror = navigator.vendor == "KDE" ? true : false;
this.Konqueror4 = this.Konqueror && /native code/.test(document.getElementsByClassName) ? true : false;
this.Gecko = !this.WebKit && navigator.product == "Gecko" ? true : false;
this.Gecko19 = this.Gecko && Array.reduce ? true : false;
})();
if (browser.IE || browser.WebKit || browser.Konqueror) {
document.write('<script type="text/javascript" src="/temp/define.js"><\/script>');
} else {
var script = document.createElement('script');
script.src = "/temp/define.js";
script.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(script);
}
#下面整个是一个str,转义后太长,我就用三个引号区分了
var s ="""
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl." : " http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-24691097-3");
pageTracker._initData();
pageTracker._trackPageview();
</script>
"""
document.write(s);#这样在FF上可以,在IE上不行。。。