1

I am making an application like Analytics, and want to find screen-resolution using JavaScript.

All the analytics tools, that are available right now (be it Google Analytics, Piwik, OWA, or any other), all of them provide screen-resolution detection.

How can I achieve the following?

EDIT: I think You all go wrong. I am making a tool similar to Analytics

EDIT 2: If you are familiar with Google Analytics, it provides with a tracking code (which is in JavaScript). When page gets loaded, script executes and you get a hit.

EDIT 3: I believe that community people got my question in wrong sense. I thought that everyone here would be familiar with Google Analytics code, But I think I have to show an example of how GA code looks like.

EDIT 4: Here how GA code looks like

<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> 
I-M-JM
  • 15,732
  • 26
  • 77
  • 103
  • Tried using `screen.width` and `screen.height` ? – Khez Apr 15 '11 at 08:31
  • Duplicate of 1000s... http://stackoverflow.com/questions/2242086/how-to-detect-the-screen-resolution-with-javascript . Search is your friend... – neurino Apr 15 '11 at 08:32
  • Just use screen.width and send it to a server? Ajax is your friend.. – halfdan Apr 15 '11 at 08:35
  • @alex: Yes, I agree with you on this. – I-M-JM Apr 15 '11 at 08:40
  • Re Edit 1: That doesn't change how you detect screen res in JS. Re Edit 2: So what? That is independent of the *detection* of the screen res. Re Edit 3/4: They haven't. – Quentin Apr 15 '11 at 08:46

1 Answers1

-1

window.screen.width and window.screen.height

Gary Chambers
  • 24,930
  • 4
  • 35
  • 31