In general, the essence is this, the site keeps logs, js determines the screen resolution and sends it to the handler in php, which logs all user data.

<script type="text/javascript"> $(function() { $.post('/log.php', { width: screen.width, height:screen.height }, function(json) { if(json.outcome == 'success') { // запрос прошёл успешно } },'json'); }); 

but if user js is disabled?

How can you get a php variable with a screen resolution (if js is turned on, of course) for one page load and send it right away, and if js is disabled, then send it without screen resolution?

In my version, everything works only when js is enabled ((

Why do you need it?

Someone clicks on advertising in Yandex, Yandex considers some clicks to be invalid, and some pass. Blocking by ip is not an option, because This ip provider is dynamic, and you can block the wrong one, so you need a maximum of data in order to enter it into the list of excluded ones in time, i.e. change ip

  • 90% of the sites in the world do not work without js. Users who disable js can safely be ignored. Sense from them is still zero. - KAGG Design
  • This is designed for intruders, and they can turn off the same - Dikkiy
  • And intruders should be banned right away, without codes and thoughts - KAGG Design
  • and for this they need to be calculated :) - Dikkiy
  • Someone clicks on advertising in Yandex, Yandex considers some clicks to be invalid, and some pass. Blocking by ip is not an option, because This provider has ip dynamic, and you can block the wrong one, so you need maximum data in order to enter it to the list of excluded ones in time - Dikkiy

2 answers 2

How to send ajax request with js disabled? No

As for the screen sizes, if you replace them with the browser window sizes (more precisely, the sizes allocated for the page), then you can use css media requests:

 body { background: url(/screen-size?large); } @media screen and (max-width: 1200px) { body { background: url(/screen-size?lte=1200); } } @media screen and (max-width: 900px) { body { background: url(/screen-size?lte=900); } } @media screen and (max-width: 600px) { body { background: url(/screen-size?lte=600); } } @media screen and (max-width: 400px) { body { background: url(/screen-size?lte=400); } } @media screen and (max-width: 200px) { body { background: url(/screen-size?lte=200); } } 

    Create a block with a user alert about the need to enable js,

     <!DOCTYPE html> ... ... <div id="js-warning"> JS ОТКЛЮЧЁН ... </div> 

    hide it with a script

     <script> document.getElementById("js-warning").style.display = "none"; </script> 

    If js is disabled, the user receives a message recommending its inclusion. The method is as old as sandals, but 100% working.

    I have not seen disabled js years since 5.