I have a CV/Resume site and when a user visits my website and the screen resolution is lower than 960 I redirect him to my mobile site through this JS
<script type="text/javascript">if (screen.width <= 960) {document.location = mobile.html";}</script>
My question is if the user wants to visit the normal site and hit a link the javascript will run again and it will redirect the user back to the mobile site. One method to solve this problem it could be to duplicate the normal site lets say index.html and index1.html one with the above code and one with no JS but i think this solution is so noobish. Any way to solve this problem? Before you answer please note that i have no access to the .htaccess file.
My problem is when a user visits my site with scree width lower than 960 go to mobile site but if he wants to see the full site press a link and get redirected to the full site no matter the screen width.
Here's a small code snippet. When the user changes from mobile to normal, run the following code:
var expires = new Date();
expires.setHours(expires.getHours + 24);
document.cookie = (document.cookie ? document.cookie + ' ;' : '')
+ ' disableMobile=1; expires=' + expires.toGMTString();
and then change your redirect condition to
if (screen.width <= 960 && document.cookie.indexOf('disableMobile') < 0) [...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With