I need what I hope is a very simple script - if a particular screen width is detected, ask the user if they want to go to the mobile site. If they say yes (Ok button), take them there, if they click Cancel, don't do anything.
I haven't been able to find an example of this, or even similar code that I could tweak (I'm too noob).
Can someone help me with this?
We were previously redirecting people automatically but had a few reports of it malfunctioning, so I want to make it optional. This is what we had before:
if (screen.width <= 1300) {
window.location('mobile.htm');
11-17-2012, 09:14 AM
ReFreezed
window.location is not a function.
Code:
if (screen.width <= 1300 && confirm('Redirect to mobile site?')) {
window.location = 'mobile.htm';
}
11-20-2012, 08:16 AM
Anon-a-mouse
Thank you! Before you responded, I managed to put something together, very close to what you have, and it's been working:
<!--
if (screen.width <= 1300) {
if(confirm("Would you like to go to our mobile site?")) document.location = 'mobile.htm';
}
//-->