-
AuthorPosts
-
December 12, 2014 at 7:13 pm #367435
Hi!
I want to use the Fullwidth button to let users close a window. I know how to do it with a normal button using this code `<button type=”button”
onclick=”window.open(”, ‘_self’, ”); window.close();”>Discard</button>`.Is this even possible?
Any help would be appreciated!Many, many thanks,
– MichaelDecember 13, 2014 at 12:18 am #367563Hi Michael,
Set a custom class to the fwd button and add this at the very end of your theme / child theme functions.php file:
function add_custom_script(){ ?> <script> (function($){ $(window).load(function() { $('.custom-fwd-btn .avia-button').on('click', function(){ window.open(”, ‘_self’, ”); window.close(); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'add_custom_script');Regards,
JosueDecember 13, 2014 at 1:42 pm #367674Hi,
I can’t really figure this out.
I’ve added the code to the end of my functions.php (child theme).
But what should I enter as custom class?
And what should I do with the button link?
Many thanks!
Regards,
MichaelDecember 13, 2014 at 1:46 pm #367677hi,
see this line of the code:
$('.custom-fwd-btn .avia-button').on('click', function(){The class is “custom-fwd-btn”
cheers
-
This reply was modified 10 years, 10 months ago by
Flikk.
December 13, 2014 at 11:01 pm #367796Hey!
Yes, the custom class should be that (custom-fwd-btn), regarding the link try putting a #.
Regards,
JosueAugust 10, 2017 at 9:47 pm #837159This one worked for me:
// Add close window functionality
function add_custom_script(){
?>
<script>
(function($){
$(window).load(function() {
$(‘.close-window .avia-button’).on(‘click’, function(){
window.open(”, ‘_self’, ”);
window.close();
});
});
})(jQuery);
</script>
<?php
}
add_action(‘wp_footer’, ‘add_custom_script’);August 12, 2017 at 1:18 pm #837850Hi afarahani,
Thank you for sharing! :)
Best regards,
Victoria -
This reply was modified 10 years, 10 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
