Facebook Twitter Reset

This Tutorial Has Been Viewed 1,422 Times.

Passing variables from javascript to php

One of the frequent problems is defining visitor’s screen resolution using JavaScript tools and passing this data to PHP-script. The script below will find the resolution of the user screen using php and pass the value to the javascript location.href part from which it is redirected to a php page.

<script language="javascript" type="text/javascript">
width = screen.width;
height = screen.height;
if (width > 0 && height >0) {
window.location.href = 'http://localhost/main.php?width='+width+'&height='+height;
} else
exit();
</script>

In this the variables ie the width and height is passed to a php page [MAIN.php]

VN:F [1.9.13_1145]
Rating: 6.0/10 (1 vote cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)
Passing variables from javascript to php, 6.0 out of 10 based on 1 rating

Incoming search terms:




You will also be interested in ,

No comments yet.

Leave a Comment

Spam protection by WP Captcha-Free

Affordable Seo PackagesSeo BlogEdu Backlinks
More in PHP, scripts (87 of 149 articles)