note 36188 added to faq.html

From: Date: Tue, 30 Sep 2003 03:29:45 +0000
Subject: note 36188 added to faq.html
Groups: php.notes 
Request: Send a blank email to php-notes+get-57370@lists.php.net to get a copy of this message
Another good way for passing javascript to php without having to have a page reload is to use an img tag. (example) Add this where you want to collect the vars from This can also be a .html page <script language="javascript"> <!--// // Define variables if (navigator.appname != 'Netscape') {color= "color="+screen.colorDepth+"&";} else {color = "color="+screen.pixelDepth+"&";} avail = "avail="+screen.availwidth+"x"+screen.availheight+"&"; res = "res="+screen.width+"x"+screen.height; isize = '" width="1" height="1" border="0"'; // Generate img tag img = '<img name="img" src="javascript.php?'+color+avail+res+isize+'">'; //Print it to browser document.write(img); //--> </script> Now you have the javascript vars passed along to the javascript.php page, all thats left is to add a couple lines of php code to gather the info up. (example) <? // Get the vars from the javascript $res = $_GET['res']; $avail_res = $_GET['avail']; $color_depth = $_GET['color']; // Do something with the info echo "You Screen's Resolution is $res, Your Available Screen Resolution is $avail_res, and the Color Depth on your screen is $color_depth."; ?> Thats it!! Hope it may help someone! ---- Manual Page -- http://www.php.net/manual/en/faq.html.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36188 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36188&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36188&report=yes

« previous php.notes (#57370) next »