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,
– Michael
Hi 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,
Josue
Hi,
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,
Michael
hi,
see this line of the code:
$('.custom-fwd-btn .avia-button').on('click', function(){
The class is “custom-fwd-btn”
cheers
Hey!
Yes, the custom class should be that (custom-fwd-btn), regarding the link try putting a #.
Regards,
Josue
This 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’);
Hi afarahani,
Thank you for sharing! :)
Best regards,
Victoria