LC Server - Check for Screen size?
matthias_livecode_150811 at m-r-d.de
matthias_livecode_150811 at m-r-d.de
Sun Mar 21 07:51:35 EDT 2021
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
> Am 21.03.2021 um 01:02 schrieb Rick Harrison via use-livecode <use-livecode at lists.runrev.com>:
>
> Hi Matthias,
>
> So you are thinking something like:
>
> <!DOCTYPE html>
> <html>
> <body>
>
> <h3>Your Screen:</h3>
>
> <div id="demo"></div>
>
> <script>
> var txt = "";
> txt += "<p>Total width/height: " + screen.width + "*" + screen.height + "</p>";
> txt += "<p>Available width/height: " + screen.availWidth + "*" + screen.availHeight + "</p>";
> txt += "<p>Color depth: " + screen.colorDepth + "</p>";
> txt += "<p>Color resolution: " + screen.pixelDepth + "</p>";
>
> document.getElementById("demo").innerHTML = txt;
> </script>
>
> </body>
> </html>
>
> And then put the information into a Javascript cookie and then read the cookie value with an LC Server script.
>
> I’ll see if I can get that to work.
>
> Thanks!
>
> Rick
>
>> On Mar 20, 2021, at 6:10 PM, matthias rebbe via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> As Livecode Server runs on the server there is no direct command/function in LC Server available for this task.
>>
>> But you could use Javascript (document.cookie) in your LC Server script to write the screen resolution into a cookie and read that cookie then with your Livecode Server script.
>>
>>
>> -
>> Matthias Rebbe
>> Life Is Too Short For Boring Code
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list