2011-04-21 41 views

回答

1

識別插件是可能的,但有點麻煩,因爲所提供的信息可能不是100%準確。有scripts like Slicer available這樣做。

您需要使用Javascript才能獲得屏幕分辨率。一些谷歌搜索結果爲a method

0

如果您正在尋找插件,如IRC,其中有一個協議,建立了它,你可以使用類似

try { 
     window.location = "protocol://etc"; 
    } catch (e){ 
     alert("Not supported"); 
    } 

掌握PHP的屏幕分辨率是不可能的,因爲PHP是一個服務器端語言。您需要爲此使用客戶端語言(如JavaScript)。

爲此,您可以使用

screen.width 
screen.height 

有了這個,你可以發送一個Ajax請求到服務器端代碼來跟蹤這一點,如果你想!

編輯:: 對於更具體的,你可以看看window.navigator.plugins過的東西(火狐特定)here

0

快速谷歌搜索拉這件事。

function alertSize() { 
    var myWidth = 0, myHeight = 0; 
    if(typeof(window.innerWidth) == 'number') { 
     //Non-IE 
     myWidth = window.innerWidth; 
     myHeight = window.innerHeight; 
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { 
     //IE 6+ in 'standards compliant mode' 
     myWidth = document.documentElement.clientWidth; 
     myHeight = document.documentElement.clientHeight; 
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { 
     //IE 4 compatible 
     myWidth = document.body.clientWidth; 
     myHeight = document.body.clientHeight; 
    } 
    window.alert('Width = ' + myWidth); 
    window.alert('Height = ' + myHeight); 
} 

http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

禮貌你必須要小心,不同的瀏覽器這個功能工作得很好。如果您使用的是jQuery(也可能是大多數其他js庫),那麼您可以在一行中完成所有這一切,並且應該很容易在Google上查找。

相關問題