SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2008
    Location
    Port Elizabeth, South Africa
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    xhtml + open link in new window

    Hi - what's the javascript to open link in a new window in xhtml since xhtml doesn't have target=blank?

    Or will browser recognize blank if xhtml 1.0 transitional is being served as text/html?
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    thanks, Val

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This has nothing to do with XHTML vs HTML. It's about Transitional vs Strict.

    XHTML 1.0 Transitional and HTML 4.01 Transitional allow the target attribute.
    XHTML 1.0 Strict and HTML 4.01 Strict do not.

    Opening a new window is an interactive behaviour, and should thus be done with JavaScript. (HTML/XHTML is for content and CSS for presentation).
    Birnam wood is come to Dunsinane

  3. #3
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Evangelist
    Join Date
    Jul 2008
    Location
    Port Elizabeth, South Africa
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi - thank you for the link! That page states: "Transitional versions of the specifications still include it, but by definition, these specs are on the way out."

    Can someone tell me how long a xhtml 1.0 transitional site will last? This is the first programming update I'm doing in 11 years (to switch from tables to css) and I hope not to do another one for at least 10 years! Will xhtml transit last that long?

    I don't know whether to follow their advice and do <a href="document.html" rel="external"> with the javascript - even though I'm in transitional - or whether to stick to <a href="document.html" target="_blank">. I want to be strict as possible, but I'm worried not all mobiles will have javascript enabled. The reason I'm switching to css is so mobiles can read site faster. Most internet access in Africa will be by mobile phone, not computer.

    thanks, Val

  5. #5
    SitePoint Zealot FaridHadi's Avatar
    Join Date
    Nov 2008
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by valarcher View Post
    ...
    but I'm worried not all mobiles will have javascript enabled. The reason I'm switching to css is so mobiles can read site faster. Most internet access in Africa will be by mobile phone, not computer.
    ...
    I don't think too many mobile phones can handle opening links in a new window, no matter which method you choose to go with.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by valarcher View Post
    Can someone tell me how long a xhtml 1.0 transitional site will last?
    The XHTML 1.0 Transitional DTD has been deprecated for nine years already and was never intended to be used when creating new documents.

    I still cannot fathom the reason why it exists in the first place. I mean, people claim to use XHTML to be 'future-proof' (which is silly, but never mind). How can one reconcile that with using a Transitional DTD that is already deprecated?

    I doubt that there are many XHTML 1.0 Transitional documents that are served as XHTML. That means they are, to all intents and purposes, HTML 4.01 Transitional. And I don't think user agents will cease to support that in a hurry.
    Birnam wood is come to Dunsinane

  7. #7
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,266
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    It'll work for a very long time. Browsers also still accept font tags and all that. Blink tags work. Marquee works. The align attribute works.

    Once I needed to have target="blank". I backed down to a transitional doctype for those pages only because I just felt it was more honest than using strict (that and I'm allergic to javascript).

    If you use the JS as posted above, those without JS will be able to open the link fine, just not in the new window. They can use the back button to go back. It's like the second most-used button on teh Interwebs.

    Is there a special reason you need "target"? 99% of the time, links should be allowed to be links.

  8. #8
    SitePoint Evangelist
    Join Date
    Jul 2008
    Location
    Port Elizabeth, South Africa
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi - thank you! So my understanding is that I must use xhtml for wordpress, and it's ok to stick to transitional so I can avoid javascript + rules are a little laxer for WP (I hear you Tommy! but WP forbids me from following you) and this will all last for ten years to 2019 - by which time hopefully I'll be rich and powerful and sexy in my 70's like Gloria Steinem + I shall hire a programmer...

    I always use target if it's a link to another site. I don't want anyone losing my site in their surfing!

    thank you! - Val

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by valarcher View Post
    I always use target if it's a link to another site. I don't want anyone losing my site in their surfing!
    Just be aware that the effect may be the opposite. I've seen a large study (done by IBM, I believe) where beginners actually got lost more easily when external links were opened in new windows. They used maximised browsers and didn't notice that a new window appeared on top of the old one. When they then tried the Back button (which every user knows) it didn't work and they couldn't find their way back.

    The best way not to lose any visitors, in my opinion, is to have sufficiently good content that people want to stay (or come back).
    Birnam wood is come to Dunsinane

  10. #10
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,266
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    ^agreed!

    Don't worry too much, most users know to navigate backwards with the Back Button. Written 10 years ago and still relevant.

    It's no mortal sin to have target="blank" on your links, but use it with caaaaare. I have disabled target in my browser because I personally don't like it (I prefer them to open in a new tab) though not everyone knows how to do this, and those with IE6 or some other older browser don't have tabs.

    Flash with target="blank" in the Actionscript url trigger my popup blocker, which is annoying. Unfortunately Flash ships with that as a default and Flash books tell people to write that code : (


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •