External links not opening in new tab in ‘advanced tooltip’ texts
-
I am unable to open url links in a new tab via the content text area using html. I’ve used the following html:
<a target="_blank" rel="noopener noreferrer">Fearless Heart</a>
I contacted a member of your team via the live chat and they replied with the following:
I’m afraid, Happy Tooltip extension is not allowing this behavior, it might be due to limitations in how the extension renders the HTML or security restrictions imposed upon it.
Is there any further clarity or a suggested fix you could offer?
I’ve tried the following JS script in the footer:
//<![CDATA[
jQuery(document).ready(function($) {
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
});
//]]>And also the following php snippet in the footer:
add_filter( 'the_content', function ( $content ) {
// This snippet requires the DOMDocument class to be available.
if ( ! class_exists( 'DOMDocument' ) ) {
return $content;
}
if ( !is_single() || !in_the_loop() || !is_main_query() ) {
return $content;
}
$dom = new DOMDocument();
$load_content = mb_convert_encoding( $content, 'HTML-ENTITIES', 'UTF-8' );
if ( empty( $load_content ) ) {
return $content;
}
@$dom->loadHTML( $load_content );
$links = $dom->getElementsByTagName( 'a' );
foreach ( $links as $link ) {
if ( strpos( $link->getAttribute( 'href' ), home_url() ) !== false ) {
continue;
}
$old_link = $link->C14N();
$link->setAttribute( 'target', '_blank' );
$link->setAttribute( 'rel', 'noopener noreferrer' );
$content = str_replace( $old_link, $link->C14N(), $content );
}
return $content;
} );However neither work for the hover tooltip text. Please could you let me knwo your thoughts and whether you can suggest a fix or a workaround?
Thank you kindly for your consideration ??
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.