Created
September 24, 2020 15:44
-
-
Save abdulawal39/fc0d310f2c52b6812315fb93d2ce4b5c to your computer and use it in GitHub Desktop.
force all links in pdf to open in a new tab - PDF Viewer for WordPress
This file contains hidden or 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
/** | |
* Put this code in your theme's functions.php file | |
* this will force all links in pdf file to open in a new tab. | |
* https://codecanyon.net/item/pdf-viewer-for-wordpress/8182815 | |
*/ | |
function tnc_pvfw_links_new_tab(){ | |
$output = '<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
document.addEventListener("textlayerrendered", function (e) { | |
jQuery("a").each(function(){ | |
jQuery(this).attr("target", "_blank"); | |
}) | |
}, true); | |
}); | |
</script>'; | |
echo $output; | |
} | |
add_action('tnc_pvfw_footer', 'tnc_pvfw_links_new_tab'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment