SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript in xhtml strict

    does anyone know of any sites that use (validating) xhtml strict, and also use javascript functions - rollovers etc?

    (the strict dtd won't allow you to use the "name" attribute, in images, so I want to find out what the solution is to this problem)

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be using id instead of name in XHTML Strict.

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, and then getElementById. Example: document.getElementById("elementId").

  4. #4
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: javascript in xhtml strict

    Originally posted by bekks
    does anyone know of any sites that use (validating) xhtml strict, and also use javascript functions - rollovers etc?
    Yep, mine.
    To make validation as clear as possible, push all CSS and javascript function code out to an external and leave only the class identifiers and function calls in the actual html doc.

    (the strict dtd won't allow you to use the "name" attribute, in images, so I want to find out what the solution is to this problem)
    It has been variously noted that including the DTD will also kill the javascript for pages where those scripts are running/called.
    It was a toss up between the DTD and the entire navigation method for my site*, so the DTD bit the dust.

    (*The site in question is a graphic design portfolio site, so please no comments about basic needs accessibility/useability.)

    That is the *only* thing that stops my pages validating in strict 100% (no errors, no warnings).

    That being said, my site kinda goes against the sentiment for what XHTML is meant to be for due to the fact that my site is 'driven' entirely by javascript.

    I code to XHTML strict wherever possible as regardless of whether the site needs to be accessible, etc... or not, it still helps create 'forward-compatible' coding habits and crisp and clean page code.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  5. #5
    SitePoint Member
    Join Date
    Apr 2002
    Location
    New Zealand
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink this worked, and validates

    thanks for the replys. this is what I ended up using, it validates, displays the random image in compliant browsers, displays the default image in NN3, 4. (got this by testing for document.getElementById)



    // arrays for the random stuff...

    imgCt=whichPic.length

    function whichone() {
    if (document.getElementById) {



    if (document.images){
    randomNum = Math.floor ((Math.random() * imgCt))
    document.getElementById("thisone").src = whichPic[randomNum];
    document.getElementById("thisone").alt = whichAlt[randomNum]
    }
    }

    else {
    whichone = ""
    }
    }


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
  •