jhonc66
asked on
Mobile redirection and Vice versa
Hi ,
I have added the following code to my website so that it redirects to a mobile version when viewing from a mobile, and works just fine, However I've got a button in the mobile version that will allow visitors to go to a desktop view in case they want to go back on their mobile device. How do I allow this.? or what shoukd I add to the button to allow this.
https://racingnsw-test.mystagingwebsite.com
Also, I use the following URL https://racingnsw-test.mystagingwebsite.com/wp-json/wp/v2/posts fro a web service to fetch the articles to display in the mobile version. If I redirect to mobile, I believe I will get redirected to http://t.m.racingnsw.com.au/ . how Can I force this specific URL to not redirect.
I have added the following code to my website so that it redirects to a mobile version when viewing from a mobile, and works just fine, However I've got a button in the mobile version that will allow visitors to go to a desktop view in case they want to go back on their mobile device. How do I allow this.? or what shoukd I add to the button to allow this.
https://racingnsw-test.mystagingwebsite.com
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "http://t.m.racingnsw.com.au/";
}
//-->
</script>
Also, I use the following URL https://racingnsw-test.mystagingwebsite.com/wp-json/wp/v2/posts fro a web service to fetch the articles to display in the mobile version. If I redirect to mobile, I believe I will get redirected to http://t.m.racingnsw.com.au/ . how Can I force this specific URL to not redirect.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Drop a cookie to flag they have not made an override. If they overrirde flag is not set AND the screen width is below your threshold, then redirect to mobile. Now, if they are on mobile and click the button to go back, make sure to first set the override flag. If the override flag is not set, they will not be redirected.
With that said, a better option to handle all of this is to build a responsive site where you have one page that can auto reformat based on the screen resolution. What you may run into with your option is duplicate content.