i have device detection in place using 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 gets user desktop version of website, however, problem occurs when user taps link on desktop site , gets redirected mobile site.
how can append #desktop
links if view desktop link has been clicked? possible?
well it's 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 best solution using session on server-side code.
Comments
Post a Comment