Posted By

BebenKoben on 05/09/15


Tagged

javascript


Versions (?)

Javascript Screen Resolutions


 / Published in: JavaScript
 

Get your screen resolution use JavaScript

  1. <h3>Your Screen Resolution is</h3>
  2. <b><h1 id="resolution"></h1></b>
  3. <h4 id="width"></h4>
  4. <h4 id="height"></h4>
  5.  
  6. <script>
  7. function getScreenResolution(){
  8. var width = screen.width;
  9. var height = screen.height;
  10. var resolution = width+" x "+height;
  11. return resolution;
  12. }
  13. function getWidth(){
  14. return "Screen width: "+screen.width+" pixels";
  15. }
  16. function getHeight(){
  17. return "Screen height: "+screen.height+" pixels";
  18. }
  19. document.getElementById("resolution").innerHTML = getScreenResolution();
  20. document.getElementById("width").innerHTML = getWidth();
  21. document.getElementById("height").innerHTML = getHeight();
  22. </script>

Report this snippet  

You need to login to post a comment.