SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard jax502's Avatar
    Join Date
    Jul 2003
    Location
    Jacksonville, FL
    Posts
    1,031
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry This will not validate...

    I'm trying to validate my page to XHTML 1.0 strict, but it always fails because of the "name" attribute in the <img> tag that is required by the javascript to create the rollover effect on the navigation buttons...Is there a workaround for this? Below is the code and the java script. Thanks!

    Here's the HTML code:
    <div id="mainnav">
    <a href="about.overview.html" onmouseover="imageOn('about')" onmouseout="imageOff('about')">
    <img src="images/mh_about_0.gif" width="173" height="23" alt="Find out more about Mortgage PhD" name="about"/></a>
    <a href="news.overview.html" onmouseover="imageOn('news')" onmouseout="imageOff('news')">
    <img src="images/mh_news_0.gif" width="173" height="23" alt="View current information and press releases" name="news"/></a>
    <a href="membership.overview.html" onmouseover="imageOn('membership')" onmouseout="imageOff('membership')">
    <img src="images/mh_membership_0.gif" width="173" height="23" alt="Learn about membership" name="membership"/></a>
    <a href="participants.overview.html" onmouseover="imageOn('participants')" onmouseout="imageOff('participants')">
    <img src="images/mh_participants_0.gif" width="173" height="23" alt="Find out more about charter members and providers" name="participants"/></a>
    </div>

    -----------------------------------------------------------------------
    The javascript is here:

    if (document.images) {
    about_on = new Image(); // Active images
    about_on.src = "images/mh_about_1.gif";

    about_off = new Image(); // Active images
    about_off.src = "images/mh_about_0.gif";

    news_on = new Image(); // Active images
    news_on.src = "images/mh_news_1.gif";

    news_off = new Image(); // Active images
    news_off.src = "images/mh_news_0.gif";

    membership_on = new Image(); // Active images
    membership_on.src = "images/mh_membership_1.gif";

    membership_off = new Image(); // Active images
    membership_off.src = "images/mh_membership_0.gif";

    participants_on = new Image(); // Active images
    participants_on.src = "images/mh_participants_1.gif";

    participants_off = new Image(); // Active images
    participants_off.src = "images/mh_participants_0.gif";

    }

    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
    }
    function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
    }
    function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
    }
    return true;
    }


    function imageOn(imgName) {
    if (document.images) {
    document[imgName].src = eval(imgName + "_on.src");
    }
    }

    function imageOff(imgName) {
    if (document.links) {
    document[imgName].src = eval(imgName + "_off.src");
    }
    }
    jax502

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Use the "id" attribute instead of "name" and document.getElementById() instead of document.images[].

  3. #3
    SitePoint Wizard jax502's Avatar
    Join Date
    Jul 2003
    Location
    Jacksonville, FL
    Posts
    1,031
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Vinnie! It works!
    jax502


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
  •