Jump to content

Re-direct homepage to mobile and tablet versions

Recommended Posts

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 by themilkmaidsupplyco
added website link
Link to comment
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.