themilkmaidsupplyco Posted November 20, 2023 Share Posted November 20, 2023 (edited) Hello! I am looking for a custom code I can inject into my site so that the home page changes depending on your screen size. I was successful in doing this for desktop vs mobile, by making a new version of the homepage with url /mobile. And then I added this code to the desktop homepage header: <script> if (document.documentElement.clientWidth <760) { window.location = "/mobile"; } </script> I am trying to do the same thing now for a tablet version and no code adjustments seem to be working. Does anyone know of a custom code that would allow me to send tablet users to the tablet version of the homepage (/tablet)? Thank you for your help! For reference, my website is https://themilkmaidsupplyco.com/ Edited November 20, 2023 by themilkmaidsupplyco added website link Link to comment
tuanphan Posted November 22, 2023 Share Posted November 22, 2023 Use this <script> if (document.documentElement.clientWidth < 992 && document.documentElement.clientWidth >= 768) { window.location = "/mobile"; } </script> replace /mobile with tablet page Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment