|
#1
|
|||
|
|||
|
[code:1:1d5a606ade]<table width="<?php
$res = $_GET["res"]; if (($res == "low") or ($res == "")) { echo ("100%"); } else if($res == "high") { echo ("80%"); } ?>" cellpadding="2" cellspacing="1" bgcolor="#DAE3F0">[/code:1:1d5a606ade] Is it possible for a browser to grab the screen resolution before a page loads and print the table size (above) based on the user's resolution? I know that this requires some javascript (to get the resolution), but does anyone here know enough to actually program this? ANY HELP IS APPRECIATED. |
|
#2
|
|||
|
|||
|
try combining php and javascript to do what you want..
[code:1:6345ba25ef] <script language="javascript"> // client side javascript // set javascript (client side) res (resolution) variable // based on php (server side) "res" value from querystring // mypage.php?res=low or mypage.php // will set table width to 100% // mypage.php?res=high // will set table width to 80% var res = <?php echo ((!isset($_GET["res"])) || ($_GET["res"] == "low") ? "100%" : "80%"); ?>; // output the <table> tag using javascript's document.write() method document.write('<table width="' + res + '" cellpadding="2" cellspacing="1" bgcolor="#DAE3F0">'); </script> [/code:1:6345ba25ef] |
|
#3
|
|||
|
|||
|
you might also want to use javascript's screen.width and screen.height properties.
|
|
#4
|
|||
|
|||
|
[code:1:077f50db1b]
<?php if(!$_GET['res']) { if(!$_COOKIE['Res']) { //set res by having javascript add the res=low/high to the bar. ?> <script language="JavaScript1.2"> <!-- if (screen.width==640||screen.height==480) //if 640x480 window.location.replace("<? echo $PHP_SELF."?res=low";?>") else if (screen.width==800||screen.height==600) //if 800x600 window.location.replace("<? echo $PHP_SELF."?res=low";?>") else if (screen.width==1024||screen.height==768) //if 1024x768 window.location.replace("<? echo $PHP_SELF."?res=high";?>") else if (screen.width==1280||screen.height==1024) //if 1280x1024 window.location.replace("<? echo $PHP_SELF."?res=high";?>") else //if all else window.location.replace("<? echo $PHP_SELF."?res=high";?>") //--> </script> <? } } $warray = array ( 640, 800, 1024, 1280 ); $harray = array ( 480, 600, 768, 1024 ); ?> [/code:1:077f50db1b] That along with what I posted above works beautifully. |
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Login Script for cPanel | Shane | Pre-Sales Questions | 10 | 11-02-2006 02:31 PM |
| [Closed] script problems | amartins | Shared Hosting Support | 4 | 05-05-2004 07:19 AM |
| [Closed] ASP MySQL No resolution for 1 week! | rkeith | Pre-Sales Questions | 3 | 04-26-2004 06:45 PM |
| Perl Script to Notify Cellphone of Email? | dmacke | Pre-Sales Questions | 0 | 10-02-2003 04:09 PM |
| Not sure where else to ask, but seeking a script... | LadyLarke | Shared Hosting Support | 6 | 05-24-2003 04:44 PM |
All times are GMT -6. The time now is 04:13 AM.









