Search code examples
apacheantjavadoc

With the javadoc target in Apache Ant, is it possible to make all external links open in a new window


The Apache Ant javadoc target allows a <link> attribute to link to external javadocs. I would like these javadocs to open in a new window (like target="_blank"), but the link attribute doesn't accept a <target> attribute that would allow me to do something like this. Is there some other way to do this apart from manually editing the links after they are generated?


Solution

  • The "bottom" element can be used in javadoc ant task. It injects html code into each files.

    <javadoc .....>
        <!--
        .....
        -->
        <bottom>
        &lt;script&gt;
        for(var i in document.links) {
            var link = document.links[i];
            if (link.href.indexOf('http') === 0) { 
                link.target = '_blank';
            }
        }
        &lt;/script&gt;
        </bottom>
    </javadoc>