Viewing 5 replies - 1 through 5 (of 5 total)
  • A simple plugin should be able to do this for you on the fly. If you can’t find anything like this already posted here, maybe I could write something up very quickly.

    Regards

    For the new window part, I use the following javascript:

    function makeNewWindows() {
    if (!document.links) {
    document.links = document.getElementsByTagName('a');
    }
    for (var t=0; t<document.links.length; t++) {
    var extlinks = document.links[t];
    if (extlinks.href.search(/http/) != -1) {
    if (extlinks.href.search('/www.example.com/') == -1) {
    extlinks.setAttribute('target', '_blank');
    }
    }
    }
    }
    window.onload = function(e) {makeNewWindows();}

    Just change the domain name to yours and place the script in the head tags or in an external JS file.

    Good luck,
    Michael.

    Thread Starter ebizdude

    (@ebizdude)

    thanks. it works

    does not work for me. I put it (completely) between the <head> tags of my header.php but on my side it shows a part for the source code:

    function makeNewWindows() { if (!document.links) { document.links = document.getElementsByTagName('a'); } for (var t=0; <!-- ---- [END] --------- -->;

    My editor (SCite) marks the code from the sign ‘<‘ on in red.
    When I replace ‘<‘ with ‘=’ I know this makes no sense) all is in black…

    Any ideas?

    I’d try it without using the editor, it seems to work in all other cases, minus with your editor.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘automatically turn all urls into links that open externally’ is closed to new replies.