Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just found an even more interesting solution, you think it could work? Entering this code in functions.php in wordpress and then inserting the shortcode [redirect] inside the page you need, will make the redirect command to mobile devices only work in this page

    //[redirect]
    function myjavascript_func( $atts ){
     return "<script type="text/javascript">
    
    windowWidth = window.innerWidth;
    <!--
    
    if (screen.width <= 767 || windowWidth <= 767) {
        window.location = "https://m.mysite.com";
    }
    //-->
    </script>";
    }
    add_shortcode( 'myjavascript', 'myjavascript_func' );

    Hi John

    I got exactly the same question as you, only want to redirect a specific page for mobile users. Allready tried plug ins and different scripts but no luck!

    Any chance you can post the solution you found to your problem?

    I just stumble across this code … Seems interesting, but if i want to apply just to one page of the website, how could i do this?

    if (screen.width < 600 || screen.height < 200) {
        window.location = 'anotherPage.html'
    }

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)