Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1309162

    Hello you smart cookies :)

    I am working on a Victim Services page that required to have a “Quick Exit / ESCAPE” that redirects and got that to work perfectly BUT now the dropdowns in the navigation have vanished. I know that it is due to the extra scripts can you please help me maybe combine the scripts so I can have the best of an escape button and a fully functioning dropdown navigation lol

    I know it is the scripts since all worked just fine and returned when I removed them. :/

    Thanks SO very much in advance!
    ~MDM Team

    #1309610

    Hey amanda-mdllc,
    Thank you for your patience, I tested your script in a code block on a test site and I added a custom ID to a special heading element to test the

    $("#get-away").on("click", function(e) {
    e.stopPropagation();
    getAway();
    });

    I also added a text link with the ID #get-away to test the

    
    $("#get-away a").on("click", function(e) {
    e.stopPropagation();
    getAway();
    });

    So while my menu sub-menu was working I found it was shifted to the left a ways, the reason was your first line in the script was calling src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js , jQuery v1.7.2, where the theme includes v3.5.1 once I removed this old version the script seemed to run ok.
    But my research pointed to return false; working better than e.stopPropagation(); , and the text link didn’t work because it needed to be $("a#get-away").on("click", function(e) and I don’t see why you are adding $("#get-away-mobile").on("click", function(e) when $("#get-away").on("click", function(e) would also work, but I left that. I then tested why the (e.keyCode == 27) only triggers the window.location.replace and not window.open and I could not find out why the key press won’t work, but I did find that window.open reportedly doesn’t work with Safari, so for this you will have to be happy with at least window.location.replace working.
    Anyways I rewrote it a little as a function you can add to your child theme functions.php file:

    function custom_getaway_script() { ?>
        <script>
    (function($){
    function getAway() {
    // Get away right now
    window.open("http://weather.com", "_newtab");
    // Replace current site with another benign site
    window.location.replace('http://google.com');
    }
    function getAwayMobile() {
    // Get away right now
    window.open("http://weather.com", "_newtab");
    // Replace current site with another benign site
    window.location.replace('http://google.com');
    }
    
    $("#get-away").on("click", function(e) {
    getAway();
    return false;
    });
    $("a#get-away").on("click", function(e) {
    getAway();
    return false;
    });
    
    $(document).keyup(function(e) {
    if (e.keyCode == 27) {
    getAway();
    }
    });
    
    $("#get-away-mobile").on("click", function(e) {
    getAwayMobile();
    return false;
    });
    
    $("a#get-away-mobile").on("click", function(e) {
    getAwayMobile();
    return false;
    });
    })(jQuery);
    </script>
        <?php
    }
    add_action('wp_footer', 'custom_getaway_script');

    Hopefully this helps.

    Best regards,
    Mike

    #1309856

    Hey there Mike!

    Thanks so much for getting that over to me. I am literally putting the website live today so I will give this script a test tomorrow and get back to you.

    Thanks so much in advance!
    ~MDM Team

    #1309911

    Hi,
    Very good, if you have any problems please link to a test page that we can check.

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.