Support » Fixing WordPress » How to make comment links open in new window?

  • I’m not using the pop-up comment script by default on my blog, so links open up in my blog’s frame. How can I code the wp-comments.php to make commenters’ links to their sites open up in new windows (ie: target=”_blank”)?
    Thanks for you help!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Eeek! Colette you had better brace yourself. Good luck 😉

    With pop-up comments it would be a disservice to guests not to have a new browser window open up. So that the page will validate, I set rel=”external” in my links and use javascript to open a browser window. You can put the following in a file called external.js and call it in the header of your page with
    <script type="text/javascript" src="external.js"></script>
    function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName(“a”);
    for (var i=0; i
    var anchor = anchors[i];
    if (anchor.getAttribute(“href”) &&
    anchor.getAttribute(“rel”) == “external”) = “_blank”;
    window.onload = externalLinks;

    And there goes your accessibilty and cross platform performance.

    And for user agents other than browsers?

    Almost 100% of my users use Netscape or IE, so I’m not worried.

    Poor users. And for persons on screen readers?

    Root, go back underground where you belong – you’re just out to trip others up (“Well that’s a joke, son”). My response shouldn’t interfere with accessibility or performance. Old browsers, etc., will treat it as a “regular” link. Anyhoo, when you aim to please everyone you make compromises that please no one.

    As long as all our readers are clear about the consequences of the construction choices they make.
    Among others.
    I’ve said before that I have problems with ‘rel=”external”‘. If you care so much about standards compliance that you are inserting unnecessary javascript to do the same thing as ‘target=”_blank”‘, what are you doing forcing people to open new windows anyway? Either embrace compliance fully or don’t bother. It is actually very simple to edit wp-comments to do what this user wants, just by changing the function calls. The question is why would anyone using a standards-compliant tool like WordPress want to.

    It is compliant.

    Fully. XHTML is one thing, DOM is another, don’t mix those 2… You don’t mix CSS and XHTML, now do you?

    The point I think some folks are trying to make is that it is relatively simple matter
    to be compliant and open a new window if someone wants to. The issue is whether opening a new window at all is a good thing. Many people here aspire to slightly more than simply validating. There is absolutely no obligation to do so.
    But folks interested in the nuts and bolts of web standards, accessibility, useability, future proofing their code and all the other doo daas, generally regard new windows as a *bad thing*. You may not agree. I have a real neat piece of code which does something very similar to what you need. It is called a back button. And it is fitted to my browser already.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to make comment links open in new window?’ is closed to new replies.