| | |
Monitor Resolution Detection for Tables
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
A very simple PHP/Javascript snippet to detect the resolution of a user's monitor and create a table using that resolution to best fit within the user's browser (to avoid scrolling). Note: This is a PHP script which includes Javascript
<?php $url = $_SERVER['PHP_SELF']; if(isset($HTTP_COOKIE_VARS["res"])) $res = $HTTP_COOKIE_VARS["res"]; else{ ?> <script language="javascript"> <!-- go(); function go() { var today = new Date(); var the_date = new Date("August 31, 2020"); var the_cookie_date = the_date.toGMTString(); var the_cookie = "res="+ screen.width +"x"+ screen.height; var the_cookie = the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location = '<?echo "$url";?>'; } //--> </script> <?php } ?> <?php //Let's "split" the resolution results into two variables list($width, $height) = split('[x]', $res); //Take the width and height minus 300 $tb_width = $width-300; $tb_height = $height-300; //Make the table print("<table align=center border=1 width=" .$tb_width . " height=" . $tb_height . " > <tr><td align=center>Your screen resolution is " . $width . " by " . $height . ".<br> The width/height of this table is " . $tb_width . " by " . $tb_height . ".</td></tr> </table>"); ?>
Similar Threads
- Win32 Error and monitor resolution changes at startup. Possible malware? (Viruses, Spyware and other Nasties)
- LCD TV Monitor Issue, Screen Resolution 800x 600 (Windows NT / 2000 / XP)
- HP Pavillion M90 Monitor and Resolution help (Monitors, Displays and Video Cards)
- Resolution 1440 * 900 (Acer Monitor) (Monitors, Displays and Video Cards)
- asus p5e vista black screen (after changing monitor resolution) (Troubleshooting Dead Machines)
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug captchaformproblem checkbox close codes createrange() css cursor debugger decimal dependent disablefirebug dom download dropdown editor element engine enter error events explorer ext file firefox form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe index internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math media menu microsoft mp4 object onmouseoutdivproblem paypal pdf php player position programming progressbar prototype redirect regex runtime safari scale scriptlets search security select size software sql text textarea unicode w3c window windowofwords windowsxp wysiwyg \n



