Forum Home
Press F1
 
Thread ID: 142959 2016-10-18 02:06:00 Problem with script to divert to a phone friendly site mzee (3324) Press F1
Post ID Timestamp Content User
1427617 2016-10-24 19:30:00 In my website I have a script which diverts the viewer to a mobile friendly mini site. It is placed in the <header>.
In this if the logged on screen is equal to or less than 750px wide it is diverted to ..../mobile/

<!--
if (screen.width <= 750) {
window.location = "kenyapages.net.nz
}
//-->

I want to do the same with other resolutions i.e 320 & 480.
What is needed is:
the logged on screen is equal to or less than 750px wide but not less than 480px it is diverted to ..../mobile/
the logged on screen is equal to or less than 480px wide but not less than 320px it is diverted to ..../mobile/
the logged on screen is equal to or less than 320px wide it is diverted to ..../mobile/

I can then have several suitable mini sites.

Help would be appreciated :)

You want media queries which are a CSS3 feature, and as previously mentioned, you might want to look at building a fully responsive website which will cater for all 3 main categories of screen sizes in the one site.
Webdevguy (17166)
1427618 2016-10-24 19:32:00 I just got shivers down my spine... Using tables for layouts actually makes making responsive websites more difficult as they don't adapt to different screen sizes very well.

Tables do work on responsive sites although they are still annoying to work with, you just need to add your responsive classes to the table.
Webdevguy (17166)
1427619 2016-10-24 21:26:00 mzee,

The problem is what screen width reports. I no longer work out the incompatibilities and would use a javascript library to do the dirty work for me. The time wasted is unneccessary and I honestly think you should change your position on these types of things.

I too came from a do it all yourself, creating my own libraries and frameworks to now relying on other peoples work so that I could just do the important things with my sites and not get tied down working out my own bugs.

Once you discover how easy it makes your life, you would never go back.
Kame (312)
1 2