You are here: Re: User Display Size « All PHP « IT news, forums, messages
Re: User Display Size

Posted by Summer on 09/23/06 04:40

Thanks Jerry. I know almost nothing about php and even less about
java. However, on the surface your code looks like it will work. One
more question if you don't mind. How do I access the height and width
values?



On Thu, 14 Sep 2006 21:01:14 +0200, <info@swadd.nl> wrote:

>Hello Summer
>
>Try this with javascript That is probably the most elegant option. Most
>likely the only option.
>
>When jou start with a php indexpage you could do something like this.
>
>Possible index.php
>
><?php
>session_start();
>
>if(isset($_POST['screenwidth'])){
> // store screenwidth in a session
> $_SESSION['screenwidth'] = $_POST['screenwidth'];
>}
>if(isset($_POST['screenheight'])){
> // store screenheight in a session
> $_SESSION['screenheight'] = $_POST['screenheight'];
>}
>
>// determine if screenwidth and heigth is already know. If not do this
>if(!isset($_SESSION['screenwidth']) || !isset($_SESSION['screenheight'])){
>?>
>// simple page for processing javascript to determine screendimensions
>
><html>
><head>
><title>Welcome</title>
>
>//simple script script
><script language=javascript1.2>
>function detectUserScreen(){
>
> /*determine width*/
> screenWidth = screen.width;
> /*determine height*/
> screenHeight = screen.height;
>
> /* Place values in form */
> document.form1.screenwidth.value = screenWidth;
> document.form1.screenheight.value = screenHeight;
>
> /* Submit form tot index.php*/
> document.form1.submit();
>}
></script>
>
></head>
><body onLoad="javascript:detectUserScreen();">
>
><!-- simpel form to contain width and height-->
><form name="form1" action="index.php" method="POST">
><input type="hidden" name="screenwidth" value="">
><input type="hidden" name="screenheight" value="">
></form>
>
><!--nice message to user if server responds slow-->
><p>Wait for just a second. Page is loading.</p>
></body>
></html>
><?
>}
>// if width and height are known do this
>else{
> // do something else e.g. go to next page
> header("location: index1.php");
>}
>?>
>
>Save the code as index.php and run it.
>
>Call your previous index.php index1.php and jour in business.
>
>Screenwidth and height are stored in a session till user closes window or
>you do session_destroy();
>
>Hope this helps
>
>Jerry
>
>"Summer" <noone@nospam.xspam> schreef in bericht
>news:122cg21mpem1nbspgv4gelqrvhecje3n36@4ax.com...
>>I want to display an image that will adjust it's size based on the
>> size of the users window. Is this possible?
>>
>>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация