#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Ottawa
    Posts
    23
    Rep Power
    0

    new window javascript and validation


    Hello,

    I've got a javascript for a new window to open up from a link on my page. However when I go to validate the document (xHTML doc) it says it is invalid because there is no attribute onclick.

    Is this cause of an accessibility issue or did I do something wrong in my script to make it non-valid?
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    It's pretty clear, the DTD for XHTML doesn't allow you to have an onclick="" in link tags, <a href="">. So I guess it's not something you really did wrong, it's just not allowed by the XHTML DTD. FYI, neither is target="" (at least not in Strict, not sure about Transitional). To use those you have to go back to the HTML 4 DTD.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Ottawa
    Posts
    23
    Rep Power
    0
    Thanks that's what i was afraid of,
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Posts
    1,882
    Rep Power
    19
    What code are you using?

    This validated for me
    Code:
    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    </head>
    
    <body>
    <p><a href="#" onclick="window.open('http://www.google.com')">link</a>
    <a href="javascript:window.open('http://www.google.com')">link</a></p>
    </body>
    </html>
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Ottawa
    Posts
    23
    Rep Power
    0
    sorry, I should have written back. I figured out why it wasn't validating and it was so simple I had to hit my head on my desk.

    The reason it didn't validate was cause I wrote onClick instead of onclick.

IMN logo majestic logo threadwatch logo seochat tools logo