Created
October 24, 2024 12:23
-
-
Save abdulawal39/0fb04575c60fea60936efd4083029924 to your computer and use it in GitHub Desktop.
Change fullscreen mode link target for TNC FlipBook - PDF viewer for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tnc_support_modify_a_tags() { | |
?> | |
<script type="text/javascript"> | |
document.addEventListener('DOMContentLoaded', function() { | |
function tnc_support_update_links() { | |
// Find all 'a' tags with the class 'fullscreen-mode' | |
const fullscreenLinks = document.querySelectorAll('a.fullscreen-mode'); | |
// Loop through the NodeList and update the target to '_parent' | |
fullscreenLinks.forEach(function(link) { | |
link.setAttribute('target', '_parent'); | |
}); | |
} | |
// Call the function to update the links | |
tnc_support_update_links(); | |
}); | |
</script> | |
<?php | |
} | |
// Hook it to the WordPress footer or wp_enqueue_scripts action | |
add_action('wp_footer', 'tnc_support_modify_a_tags'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment