homepage Welcome to WebmasterWorld Guest from 54.197.19.35
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Detect screen resolution and pass it to PHP using AJAX (no refresh)
How to find user's screen resolution and pass it to PHP using AJAX
colombo




msg:4368905
 9:11 pm on Sep 29, 2011 (gmt 0)

I'm trying to find the user screen resolution via Javascript and then pass it to PHP on the same page using AJAX without refreshing the page.

I manage to find the screen resolution , but i have no idea how to use AJAX in order to pass the variables to PHP without refreshing the page.

I search the forum and didn't find a got example, please help.

I have:
<script language="javascript">
var viewportwidth;
var viewportheight;
viewportwidth = window.innerWidth,
viewportheight = window.innerHeight
</script>

Now i need help to use viewportwidth and viewportheight as PHP variables.

Thanks...

 

httpwebwitch




msg:4370160
 4:51 pm on Oct 3, 2011 (gmt 0)

You won't be able to use these client-side variables in the *same PHP script* that rendered the current page. The best you can achieve is to send the screen data to the server, then the server can use it the *next* time it renders something.

There are lots of nifty tricks you can do, making a second request to the server, to get content that is formatted for a particular screen size, and using DOM techniques to update the current page. It's all possible without a refresh.

i have no idea how to use AJAX


then you've got some reading to do!

start here:
[w3schools.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved