Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Artur Słaboszewski
Added: Jun 5, 2020 3:11 PM
Views: 124
Tags: jquery js
  1.  
  2. function checkResolution() {
  3.  
  4.         function resolution(){
  5.                 let res = 'Browser res: '+screen.width + "x" + screen.height + '<br>Device res: ' + window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio;
  6.                 console.log(res);
  7.                 if($('#res-info').length==0) {
  8.                         $('body').append('<div id="res-info" style="position:fixed;z-index:9999;background:orange;color:#111;top:10px;right:5px;font-size:10px;padding:3px;opacity:.8">'+res+'</div>').show();
  9.                 }
  10.                 else {
  11.                         $('#res-info').html(res);
  12.                 }
  13.         }
  14.  
  15.         resolution();
  16.         $(window).on('resize', function(){
  17.                 resolution();
  18.         })
  19.  
  20.  
  21.         $('#res-info').on('click',function(){$(this).hide()});
  22. }