Home › Forums › Any Mobile Theme Switcher › Can we switch the theme on window resize function?
- This topic has 3 replies, 2 voices, and was last updated 9 years, 7 months ago by Dinesh.
-
AuthorPosts
-
September 15, 2014 at 7:19 am #3498BhaskarGuest
I just wanted to see if i could use your plugin to switch theme on specific window width within window resize event. Is there any hook so that i could trigger em up for this purpose?
September 15, 2014 at 11:59 am #3501DineshKeymasterHi Bhaskar,
That is not possible with our plugin. We deal with User Agent and all redirect are handle by PHP. So change in theme when browser resize isn’t possible with this one.
Only possible for this is getting a responsive theme.
Thanks
September 15, 2014 at 1:54 pm #3502BhaskarGuestThank you for the quick response.
Just to let you know my scenario.
I am dealing with a site which has two version of theme,
i). desktop version and ii. mobile version
I have managed to switch the theme with the help of ajax on jquery’s window.resize function and overwriting the current document with html ajax response.var mobilecall = false; var desktopcall = false; jQuery(document).ready(function() { if (jQuery(window).width() > 940) { switch_desktop_theme(true); } jQuery(window).resize(function() { var width = jQuery(window).width(); if (width < 940 && mobilecall === false) { desktopcall = false; switch_mobile_theme(false); } else if (width > 940 && desktopcall === false ) { mobilecall = false; switch_desktop_theme(false); } }); }); function switch_mobile_theme(initial) { if (initial !== true) { mobilecall = true; } //// console.log('yay, mobile theme loaded'); // jQuery.ajax({ // type: 'post', // url: "<?php echo $mobile_url; ?>", // dataType: 'html', // success: function(result) { //// jQuery('html').html(result); //// preventDefault(); // document.write(result); // document.close(); // } // }) } function switch_desktop_theme(initial) { if (initial !== true ) { desktopcall = true; } // console.log('yay, mobile theme loaded'); jQuery.ajax({ type: 'post', url: "<?php echo $desktop_url; ?>", dataType: 'html', success: function(result) { // jQuery('html').html(result); // preventDefault(); document.write(result); document.close(); } }) } </script>
September 16, 2014 at 3:55 am #3507DineshKeymasterHi Bhaskar,
That’s great to know about it. You have managed to do it.
🙂
-
AuthorPosts
- The topic ‘Can we switch the theme on window resize function?’ is closed to new replies.