Can we switch the theme on window resize function?

Home Forums Any Mobile Theme Switcher Can we switch the theme on window resize function?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3498
    Bhaskar
    Guest

    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?

    #3501
    Dinesh
    Keymaster

    Hi 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

    #3502
    Bhaskar
    Guest

    Thank 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>
    #3507
    Dinesh
    Keymaster

    Hi Bhaskar,

    That’s great to know about it. You have managed to do it.

    🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Can we switch the theme on window resize function?’ is closed to new replies.