Data transfer from JavaScript to PHP -


How do I get the height and width of the browser php? Like a data transfer from JavaScript to PHP? With using inner height and inversion , I think.

(I need to show a small picture of the user if he has a small screen size and large if there is no data about large and no screenset I)

I think:

  & lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Link rel = "stylesheet" href = "css / slideshow.css" type = "text / css" /> & Lt; Script & gt; Document.write ('script.php? Screen =' + screen.width + 'x' + screen. ''); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php $ lol = $ _ GET ['Screen']; & Lt ;? Php echo "Size: $ lol"? & Gt; & Lt; / Body & gt; & Lt; / Html & gt;  

And does it work? What am I doing wrong?

You have to make an AJAX call from Javascript to PHP scripts. That PHP script will save the screen resolution in the current session (you have to use the session for this). A PHP script which was requested at a later point, can access the screen resolution passed by the JavaScript snippet.


Comments