Page 1 of 1

Detecting mobile browser

Posted: Sun Jan 05, 2025 6:44 pm
by Lubomír Ludvík
Web looked bad on a mobile device, so I detecting mobile browser and reducing the image preview.

Code: Select all

<script>
if(/Android&#124;webOS&#124;iPhone&#124;iPad&#124;iPod&#124;BlackBerry&#124;IEMobile&#124;Opera Mini/i.test(navigator.userAgent)){
  document.currentScript.outerHTML = `[img=images/mapka_apartmany.jpeg scale=5% float=right]`;
}else{
  document.currentScript.outerHTML = `[img=images/mapka_apartmany.jpeg scale=18% float=right]`;
}
</script>
Is extension that detects the mobile and change the template or change .css?

Re: Detecting mobile browser

Posted: Mon Jan 06, 2025 2:30 am
by Lubomír Ludvík
and I change css style:

Code: Select all

@media only screen and (max-width: 480px) { ... }

Re: Detecting mobile browser

Posted: Thu Jan 09, 2025 11:14 pm
by fraenkiman
Hello Lubomír,

try the mobile plugin. The code may need to be updated.

Have a good weekend
With best regards
Frank

Re: Detecting mobile browser

Posted: Sun Jan 12, 2025 12:59 pm
by Arvid
Ahoj Lubomír,

šťastný nový rok! :D

The Mobile plugin works fine, I use it on my personal website.
But it's basically a workaround; the best way to serve a good layout to big and small screens is proper use of responsive web design.
Check out https://flatpress.org for example :)

All the best,
Arvid