Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <script>
  2. var x = screen.availWidth;
  3. var y = screen.availHeight;
  4.  
  5. alert("LARGURA: "+ x +"nALTURA: " + y)
  6. </script>
  7.  
  8. $(function() {
  9. $.post('alerta.php', { width: screen.width, height:screen.height }, function(json) {
  10. if(json.outcome == 'success') {
  11. // do something with the knowledge possibly?
  12. } else {
  13. alert('Impossível deixar o PHP saber a resolução da tela!');
  14. }
  15. },'json');
  16. });
  17.  
  18. <?php
  19. // Você pode fazer algo parecido com isto:
  20. if(isset($_POST['width']) && isset($_POST['height'])) {
  21. $_SESSION['screen_width'] = $_POST['width'];
  22. $_SESSION['screen_height'] = $_POST['height'];
  23. echo json_encode(array('outcome'=>'success'));
  24. } else {
  25. echo json_encode(array('outcome'=>'error','error'=>"Não é possível definir a resolução."));
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement