1
我正在製作一個類似Google Analytics的應用程序,並希望使用JavaScript查找屏幕分辨率。使用javascript的屏幕分辨率
所有現在可用的分析工具(無論是Google Analytics,Piwik,OWA還是其他)都可以提供屏幕分辨率檢測。
我該如何做到以下幾點?
編輯:我想你們都出錯了。我正在製作類似於Google Analytics的工具
編輯2:如果您熟悉Google Analytics,它會提供跟蹤代碼(使用JavaScript)。當頁面被加載時,腳本執行並且你得到一個命中。
編輯3:我相信社區人士錯誤地理解了我的問題。我認爲這裏的每個人都會熟悉Google Analytics代碼,但我認爲我必須展示GA代碼的樣子。
編輯4:GA代碼下面的樣子
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456789-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
使用'screen.width'和'screen.height'試過嗎? – Khez 2011-04-15 08:31:40
重複的1000年... http://stackoverflow.com/questions/2242086/how-to-detect-the-screen-resolution-with-javascript。搜索是你的朋友... – neurino 2011-04-15 08:32:17
只需使用screen.width並將其發送到服務器?阿賈克斯是你的朋友.. – halfdan 2011-04-15 08:35:52