Ready to get started?Download WordPress


Commentors Links Open In New Window (6 posts)

  1. p5hng
    Posted 10 years ago #

    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!!

  2. unoamigo
    Posted 10 years ago #

    Furthermore, you edit the appearance of the pop-up window in this file:

  3. p5hng
    Posted 10 years ago #

    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.

  4. Beel
    Posted 10 years ago #

    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")
    anchor.target = "_blank";
    window.onload = externalLinks;
    and call it in the head of your page with:
    <script type="text/javascript" src="external.js"></script>

  5. OperaManiac
    Posted 10 years ago #

    Sushubh very true, never noticed, pretty cool!!!

  6. p5hng
    Posted 10 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.