<script> var widthBlock = $('#block').width(); document.write(widthBlock); </script> As the value that is output by document.write(widthBlock); put a variable in PHP?
<script> var widthBlock = $('#block').width(); document.write(widthBlock); </script> As the value that is output by document.write(widthBlock); put a variable in PHP?
The variable can be passed to PHP via a cookie or sent by an ajax request. For me, the second is better. It will look something like this.
<script> var action = 'your_script.php'; var widthBlock = $('#block').width(); $.post(action, { var_name: widthBlock }, function()); </script> Another such moment. To determine from which user the information came in the php script, you can use the PHP session ID. It will simultaneously be stored and match in the PHP script and in the browser cookie.
Read more about sessions in PHP: http://www.php.su/articles/?cat=examples&page=070
Library for working with cookies from JS: https://github.com/js-cookie/js-cookie
This solution is ideal for your case:
var widthBlock = $('#block').width(); window.location.href = "index.php?widthBlock=" + widthBlock; To get the widthBlock value, you need to refer to the $ _GET ['widthBlock'] variable in the index.php file
Source: https://ru.stackoverflow.com/questions/519260/
All Articles