0

I have device detection in place using the following code:

<script>
if( /Android|webOS|iPhone|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent) ) {

if(window.location.hash == "#desktop"){
    // Stay on desktop website
} else {
    window.location = "<?php bloginfo('url'); ?>/m";
} 
}
</script>

This works in that it gets the user back to the desktop version of the website, however, my problem occurs when a user taps a link on the desktop site and then gets redirected to the mobile site.

How can I always append the #desktop to all links if the View desktop link has been clicked? Is this possible?

egr103
  • 3,858
  • 15
  • 68
  • 119
  • Possible duplicate: http://stackoverflow.com/questions/15106159/useragent-switcher-to-mobile-web – Uooo Mar 27 '13 at 09:03

1 Answers1

0

well it's just an idea,

  if(window.location.hash == "#desktop"){
    $(function(){
        $(document).find('a').click(function(e){
           e.preventDefault();
           window.location.replace($(this).attr("href")+"#desktop");
        });
    });
 }

or

   if(window.location.hash == "#desktop"){
     $(function(){
       $(document).find('a').attr("href",$(this).attr()+"#desktop");
     });
   }

I think the best solution is using SESSION on server-side code.

egig
  • 4,370
  • 5
  • 29
  • 50