我正在运行一个集成了WhichBrowser的html页面。WhichBrowser集成错误
正如README文件解释说,我已经把下面的代码(在<head>
部分):
<script>
(function(){var p=[],w=window,d=document,e=f=0;p.push('ua='+encodeURIComponent(navigator.userAgent));e|=w.ActiveXObject?1:0;e|=w.opera?2:0;e|=w.chrome?4:0;
e|='getBoxObjectFor' in d || 'mozInnerScreenX' in w?8:0;e|=('WebKitCSSMatrix' in w||'WebKitPoint' in w||'webkitStorageInfo' in w||'webkitURL' in w)?16:0;
e|=(e&16&&({}.toString).toString().indexOf("\n")===-1)?32:0;p.push('e='+e);f|='sandbox' in d.createElement('iframe')?1:0;f|='WebSocket' in w?2:0;
f|=w.Worker?4:0;f|=w.applicationCache?8:0;f|=w.history && history.pushState?16:0;f|=d.documentElement.webkitRequestFullScreen?32:0;f|='FileReader' in w?64:0;
p.push('f='+f);p.push('r='+Math.random().toString(36).substring(7));p.push('w='+screen.width);p.push('h='+screen.height);var s=d.createElement('script');
s.src='http://localhost/mysite/libs/whichbrowser/detect.js?' + p.join('&');d.getElementsByTagName('head')[0].appendChild(s);})();
</script>
然后将下面的代码(在<body>
):
<script>
Browsers = new WhichBrowser();
alert("You are using " + Browsers);
</script>
我m运行在easyPHP上,而.htaccess被考虑在内,所以.js被PHP解释器解析。
运行页面时(当然是从服务器),我得到Browsers = new WhichBrowser();
行上的以下错误:“WhereBrowser未定义”。
我做错了什么?
不知道,但你永远不需要知道用户正在运行的浏览器。几乎没有什么是可以的基准站点像jsperf ... –
有JavaScript文件(detect.js)加载的代码片段加载时运行底部代码段? –
@NiettheDarkAbsol:你知道一种强制所有浏览器对CSS3行为进行屏幕和打印的方式完全相同的方法,当你没有足够的时间和资源来测试所有的CSS和/或为所有现有的CSS调整CSS时浏览器? – Oliver