/    Sign up×
Community /Pin to ProfileBookmark

<a href="blabla.html" target="_blank"> not valid</a>

I get this error when trying to validate my page as xhtml

[code]Error Line 222 column 41: there is no attribute “target”.

…><a href=”img/gallery/=O.JPG” target=”_blank”><img src=”img/gallery/=O.JPG” h[/code]

My question: How to open a link in a new window in valid xhtml?

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 08.2006 — My question: might you reconsider the need to open a new window? (The basic idea here is that various user agent options may prevent such data from being presented, such as pop-up blockers and other browser options the user may have enabled.)

If you are not worried about this and only care about being able to say, "My markup passed the w3.org validator," then your likely option is to use JavaScript to open the window (which, of course, is probably even more likely to be stopped by pop-up blockers).
Copy linkTweet thisAlerts:
@acemoauthorJan 09.2006 — I basicly got my gallery to open the pictures in a new window.

javascript is not an option for me, my site is and will be 100% w.o javascript.

http://80.60.218.3/oob.com/gallery.php

heres the page if u wanna kno (yes am gonna make thumbnails for the pics, i kno they load LONG atm)

What do u think will be best option?

1) redirect em to a page with the picture and a back button.

2) just link straight to the picture (in the same window).

3) something else.
Copy linkTweet thisAlerts:
@felgallJan 09.2006 — The current web standards say that you should leave it to your visitors to decide when they want to open a page in a new window and when they want to reuse the existing one. All of the target attributes have therefore been deprecated. You can therefore still get your page to validate if you use a transitional doctype but not with a strict one.
Copy linkTweet thisAlerts:
@v_LnJan 09.2006 — I know you said your site would be 100% w/o javascript but incase you reconsider this will convert your valid links into ones which will open in a new window. and it is not effected by popup blockers.

[code=php]// Create valid external Links

function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;[/code]


then on whichever links you want to open in a new window use something like :

[code=php]<a href="http://www.blah.com/" rel="external" >Valid link</a>[/code]

note the rel="external" this is what is required to change it so it opens in a new window.


  • - i cant take credit for this script but i cant seem to find where i found it either to give proper credit >.<
  • Copy linkTweet thisAlerts:
    @FangJan 09.2006 — - i cant take credit for this script but i cant seem to find where i found it either to give proper credit >.<[/QUOTE] Possibly http://www.sitepoint.com/print/1041

    The method adds invalid attributes; your just fooling the W3C validator, but it doesn't make it valid!

    Let the user decide. Right click "Open link in ..."
    ×

    Success!

    Help @acemo spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...