(Opens in a new window) when Target is checked in RTE link
Hi All
Does anyone know if its possible to automatically append “(Opens in a new window)” to the alt attribute of links added via the RTE in Umbraco v8 only when the Target box is checked?
Currently the only way I know how requires the author having to physically type it at the end of the Link title every time but we have 3 large sites with over 700 external links each so that’s going to be a lot of work. It doesn't need to print to the page, Or even be visible in the 'Link Title' section below but needs to print into the title attribute in the HTML.
They are Local Government websites and in the UK we have a legal obligation to meet Accessibility Regulations. This is something I would like to get ticked off my list. I have looked through TinyMCE documents and searched this forum but can’t see an answer anywhere. Has anyone attempted to do this?
The alt attribute isn't actually valid for <a> you should append it to the title attribute, which you could do with some javascript code in your view. SOmething like below
// getting all anchor tags
let links = document.getElementsByTagName('a');
// looping through all the HTMLCollection links
for (let index=0; index<links.length; index++){
// accessing the target attribute from each element
let target = links[index].target;
if(target === "_blank"){
let title = links[index].getAttribute('title')
links[index].setAttribute('title', title + "Whatever you want to add");
}
}
(Opens in a new window) when Target is checked in RTE link
Hi All
Does anyone know if its possible to automatically append “(Opens in a new window)” to the alt attribute of links added via the RTE in Umbraco v8 only when the Target box is checked?
Currently the only way I know how requires the author having to physically type it at the end of the Link title every time but we have 3 large sites with over 700 external links each so that’s going to be a lot of work. It doesn't need to print to the page, Or even be visible in the 'Link Title' section below but needs to print into the title attribute in the HTML.
They are Local Government websites and in the UK we have a legal obligation to meet Accessibility Regulations. This is something I would like to get ticked off my list. I have looked through TinyMCE documents and searched this forum but can’t see an answer anywhere. Has anyone attempted to do this?
Thanks
Ben
The alt attribute isn't actually valid for
<a>
you should append it to the title attribute, which you could do with some javascript code in your view. SOmething like belowSpot on Huw. Thank you very much for your help!
is working on a reply...