WordPress.org

Forums

[resolved] Change 'target=_blank' to be XHTML friendly (5 posts)

  1. huckmag
    Member
    Posted 7 years ago #

    Hi,

    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:
    target="blank"
    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;"
    instead?

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

    Thanks!

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    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.

  3. huckmag
    Member
    Posted 7 years ago #

    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.

  4. damonjablons
    Member
    Posted 6 years ago #

    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

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic