How to make links with target=blank xhtml-strict?

Requested and Answered by Anonymous on 2005/6/8 7:32:54

How to make links with target=blank xhtml-strict?

When you want to make your XOOPS xhtml-strict you have to watch out for a few things that differ from xhtml-transitional. One of these things is that target=blank is not allowed in xhtml-strict. I know that making XOOPS xhtml-strict is ahead of time, since XOOPS struggles to be xhtml-transitional, but I wanted to let you know. Add this function between the head-tags of your theme:

<script type="text/javascript">
<!--
function 
externalLinks() {
 if (!
document.getElementsByTagName) return;
 var 
anchors document.getElementsByTagName("a");
 for (var 
i=0i<anchors.lengthi++) {
   var 
anchor anchors[i];
   if (
anchor.getAttribute("href") &&
       
anchor.getAttribute("rel") == "external")
     
anchor.target "_blank";
 }
}
//-->
</script>
Also there must be an onload of this function inside the body-tag, like:
<body onload="externalLinks();">
Also class/module.textsanitizer.php must be changed. Look for
target="_blank"
and replace with
rel="external"
And this is the method how links that have to be opened in a new window must be written. Just add rel="external" to any link that has to open in a new window. I must confess that I don't know where the credits for the above snippet have to go to and how to place the function more elegant.

This Q&A was found on XOOPS Web Application System : https://xoops.org/modules/smartfaq/faq.php?faqid=486