LC Server - Check for Screen size?

Rick Harrison harrison at all-auctions.com
Sun Mar 21 11:14:42 EDT 2021


Hi Matthias,

Thanks!

Rick

> On Mar 21, 2021, at 7:51 AM, matthias rebbe via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi Rick,
> here's a sample with some put commands and comments for better understanding.
> <?lc
> -- read Cookie screeres if available
> put $_COOKIE["screenres"] into tScreenRes
> 
> if tScreenRes is empty
> then
> 	put "cookie not found. we need to write the cookie<br>"
> -- the cookie does not exists or is empty, so we now executing JS, but 
> -- the following closing tag is mandatory, otherwise the js is not executed
> ?>   
> <script>
> 	let screenwidth = (screen.availWidth);
> 	let screenheight =(screen.availHeight);
> 	document.cookie = "screenres="+screenwidth +","+screenheight;
> </script>
> <?lc
> 	put "cookie written<br>"
> else
> 	put "Cookie already there<br>"
> end if
> 
> --now we extract height and width from the var tScreenRes
> set the itemdelimiter to ","
> put item 1 of tScreenRes to tWidth
> put item 2 of tScreenRes to tHeight
> 
> --from here take action according the detected screenresolution.
> ?>
> 
> 
> Note: The above script detects and uses the available screen resolution. 
> Regards,
> 
> 
> -
> Matthias Rebbe
> Life Is Too Short For Boring Code
> 





More information about the use-livecode mailing list