Support » Fixing WordPress » Commentors Links Open In New Window

  • This is probably extremely simplistic, but as I am relatively new to using PHP (and amazed by how easy and fast it is to use!) I have encountered a slight problem. On my comments page when I click on a commentor’s URL, it opens the link in the same window. How would I get it to open in a new window? I know about the HTML coding with target=”_blank”, but I’ve tried incorporating that with the PHP variable and it doesn’t seem to work. Any help is appreciated!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Furthermore, you edit the appearance of the pop-up window in this file:

    You’re misunderstanding which link I’m talking about, I think. ;D When someone leaves a comment, when I click on the link to THEIR home page, THAT is the link that I want to appear in a new window, not the comments page itself.

    Don’t know how I missed that on first read. The link to their site has rel=”external” in it so you can use javascript to do that. You can save this in a file called external.js:
    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 call it in the head of your page with:
    <script type=”text/javascript” src=”external.js”></script>

    Thank you very much! That is exactly what I was looking for. 😀

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Commentors Links Open In New Window’ is closed to new replies.