Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #414925

    Hi,

    I am creating a custom quick escape button based on the following code”

    ‘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() {

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

    $(“#get-away a”).on(“click”, function(e) {
    // allow the (?) link to work
    e.stopPropagation();
    });

    $(document).keyup(function(e) {
    if (e.keyCode == 27) { // escape key
    getAway();
    }
    });

    });’

    where should I place this code if I want it to appear on every page?

    thanks!

    #414927

    Hi MindSpark!

    Please try adding following code to Functions.php file in Appearance > Editor – http://pastebin.com/kWZqmH00

    Best regards,
    Yigit

    #414952

    thanks Yigit. the code is in but nothing is visible. it should look like this: https://css-tricks.com/examples/OpenCloseWindow/

    I placed the button html in a footer widget but nothing is visible

    #414954

    Hi!

    Can you post the link to your website as well?

    Regards,
    Yigit

    #414955

    thanks Yigit. http://lbdsociety.org

    #414956

    the button is visible now, but :

    1. nothing happens when I click on it
    2. how can I float the button so that is always at the bottom right of the screen?

    #415473

    hello?

    #416089

    Hi!

    Try with this code instead:

    function add_custom_script(){
    ?>
    <script>
    (function($){
        $(window).load(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');
        	}
    
        	$("#get-away").on("click", function(e) {
    	    	getAway();
        	});
    
        	$(document).keyup(function(e) {
        		if (e.keyCode == 27) { // escape key
        			getAway();
        		}
        	});
        	
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Please note that debugging third-party custom scripts is outside our support scope.

    Best regards,
    Josue

    #416101

    thanks for trying to help.

    that didn’t work either :(

    #416117

    I’m not seeing it added on your install yet. I’ve tested that on my local install and it did work.

    Cheers!
    Josue

    #416125

    When I load that code in the child theme functions.php file, the whole site turns white and I cant access it..? weird

    #416130

    actually, it works fine in the parent theme,,,, thanks!

    but not in the child theme

    #416144

    Well, must be a syntax error somewhere in your child theme functions.php.

    Cheers!
    Josue

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