Support » Fixing WordPress » Change ‘target=_blank’ to be XHTML friendly

  • Resolved huckmag



    On the website I setup the contributors really want external links to open in a new window. I’ve argued against this but I’m not going to win this argument.

    If you select ‘open in new window’ when you put a link in the visual editor it adds:
    to the link. This however is not valid XHTML.

    is there anyway I can edit the source files to make it add:
    onclick="targetBlank(this.href);return false;"

    if anyone knows where I can locate this in the code I will be hugely grateful.


Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    The target attribute is valid in XHTML 1.0 Transitional (not in Strict). So, this is what we recommend you use as your DOCTYPE for now, until the tools and utilities (like TinyMCE) catch up to the newer specs.

    Otto42 – Thanks for your reply.

    I’ve changed my site to Transitional XHTML. I’m not hugely keen on letting the bloggers use the target attribute as someone will probably have to go through and change them all at some point.

    Oh well, it’s their call if they really want links to open in a new window.

    I don’t know if anyone is still interested in this, but I personally like all my code to be Strict because it reflects better upon me as a web developer. Transitional is also not supposed to be used, and people really should be moving completely over to strict.

    In any case, I wrote a wordpress plugin which will replace your target=”_blank” links with rel=”external” and it will also insert the necessary javascript.

    Here’s the download link: zshare link

    if you have any questions: damon jablons at gmail dot com

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Transitional is also not supposed to be used

    Dunno where you got that idea, but it’s false. If it was not supposed to be used, then a) it would not exist and b) it would not be a standard.

    XHTML 1.0 Transitional is the current best choice because it is the most compatible with current browsers. If/when IE gets its act together and ceases to suck, then I would not recommend moving to Strict, I would recommend moving to XHTML 1.1 instead.

    My own blog is currently using XHTML+RDFa 1.0, but that’s because I needed RDF code in it for some microformats and wanted it to validate those.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change ‘target=_blank’ to be XHTML friendly’ is closed to new replies.