开发者

Checking what plugins a user has installed

How can you find out what plugins a firefox/chrome user has installed using php? Also is it possible to find开发者_Python百科 out their screen resolution?


Identifying plugins is possible but kind of messy since the information presented may not be 100% accurate. There are scripts like Slicer available to do this.

You need to use Javascript to obtain the screen resolution. Some googling turned up a method for doing this.


If you're looking for plugins such as IRC, which have a protocol set up for it you can use something like

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

Getting the screen resolution with php is impossible, as php is a server side language. You will need to use a client side language for this (such as javascript).

For this you can use

screen.width
screen.height

With this you can send an ajax request to your server side code to keep track of this if you want!

Edit :: For something more specific you can look at window.navigator.plugins too (firefox specific) here


Quick google search pulled this up.

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 );
}

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

You have to be careful with different browsers this function work pretty well. If you're using jQuery (and probably most other js libraries) there's a function where you could do all that in 1 line and that should be easy to find over google.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜