I need to set all links within a rich text field to open in a new tab by default. The rich text field will probably have a style attached to it, if that matters. The reason is that I have rich text fields with dozens and sometimes hundreds of links and it’s not feasible to go through the multiple little clicks needed to set “open in new tab” for each one individually (this is a UI problem in Webflow imo).
My understanding is this is done using custom code. I have tried both of the following and neither work. Can someone help?
Hello! The second link you posted worked for me. I just pasted the code into my Project Settings > Custom Code section inside the Footer Code.
The script below is the one that worked for me:
jQuery(document).ready(function() {
$('*[data-rt-link-type="external"]').attr("target", "_blank");
$( "a" ).attr("target", "_blank");
});
Hope this works for you!
Edit: So this works - for me - on Chrome, Firefox, and Edge, but NOT on Safari. I don’t know the answer to that… looks like this won’t work for me either.