Results 1 to 15 of 15

Thread: HTML sinner can't repent!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Yewston, Texis
    Posts
    240

    HTML sinner can't repent!

    I tried running my code through the w3c validation service:
    http://validator.w3.org/

    It said that name="x" was an illegal attribute of <img>.

    But, when I change it to id="x" the validator likes it, but then this JavaScript line fails:
    document.x.src=picture;

    I want validated code, but I also want my rollovers to work. Any ideas?

    cudabean

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Why worry about validation? Do you know how much crap that gives me, but my stuff works in all browsers? I just don't see why it matters.

    According to the code validation in HomeSite 4.5, it doesn't give me any errors with name="x", but it also doesn't show name as an attribute of the img tag.

    I personally wouldn't worry about it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Line 9, column 56:
    <td><img src="http://www.vbshelf.com/corner.gif"></td>
    ^
    Error: required attribute "ALT" not specified
    You gotta be kidding me...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    If you validate it you know it should work on all browsers, as long as they aint buggy. Anyway it's up to you if you want to validate or not but here's how to get round the name/id thing:

    Code:
    //Modern W3C Compliant browsers:
    if (document.getElementById) {
      document.getElementById('x').src=picture;
    }
    //Old NS browsers:
    else if (document.layers) {
      document.layers['x'].src=picture;
    }
    //Old IE browsers:
    else if (document.all) {
      document.all['x'].src=picture;
    }
    Oh by the way the ALT thing is required because if the image ain't found or the user is using a blind/braile/etc browser they will see nothing, so you should provide ALT so that will get shown instead of the picture.

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by Rick Bull
    Oh by the way the ALT thing is required because if the image ain't found or the user is using a blind/braile/etc browser they will see nothing, so you should provide ALT so that will get shown instead of the picture.
    although it is seriously annoying if you have images as bullets, and transparent spacer gifs. I mean, they still need an alt, which is pretty damn stupid

    Hi. this is a spacer!
    Hi there, I am a curve on the end of this table to make it look nicer! But I still need an alt tag

  6. #6
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Well you can just make alt="", but the proper way to do images as bullets or spacers is to use CSS. If you want me to dig out the bullet thing I will. But for the spacers you can use:

    Code:
      <div style="margin: 1px 3px 5px 2px;">This is spaced 1px down from the top, 3px in from the righ, 5px from the bottom and 2px from the right.</div>
    Or you can use padding if you want to just indent the stuff inside the div/other element.

  7. #7
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    I decided to find it anyway :

    Code:
    ul {
      list-style-image:url('Images/LI.png');
    }
    I think you can use it for li if you prefer, i.e. different classes for differnt 'li's in the same ul

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Now that's wack...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Name is deprecated in favour of ID. The way the get around this (and for backwards compatibility) is to use id and name in the img tag.

    Also, using document.images instead of document.x.src=picture;

    Code:
    document.images['x'].src=picture;
    document.images[1].src=picture;
    I gave up running my code through the W3C validator, it always finds new 'problems' that I wasn't even aware of.

    and Rick, you know damn well we dont talk like that
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  10. #10
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Hey Punk, what other elements can you refer to in that method? I want to change the display of a div from/to block & none. I'm doing it using getElementById at the moment, is that the best way?

  11. #11
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    theres a few different things you can do. One you use a lot is probably document.forms. Theres also getElementByName('elementName') and a few others

    http://www.w3.org/TR/REC-DOM-Level-1...e-binding.html

    Its about a third of way down
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

  12. #12
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Thanks, that's just what I wanted. I've been wondering if there was a doc with all that info, but I'm too lazy to check the W3C site

  13. #13
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Originally posted by chrisjk
    although it is seriously annoying if you have images as bullets, and transparent spacer gifs. I mean, they still need an alt, which is pretty damn stupid

    Hi. this is a spacer!
    Hi there, I am a curve on the end of this table to make it look nicer! But I still need an alt tag
    If you don't give them an alt="", they show up (in lynx) as [IMAGE] rather than nothing, so imagine a blind person sitting there impatient as "image image image image image" is spoken aloud to him.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  14. #14
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Originally posted by chrisjk
    Hi there, I am a curve on the end of this table to make it look nicer! But I still need an alt tag
    We are supposed to be getting nice little curvy tables features (more genericly, borders with rounded corners) in the next round of HTML/CSS. This means, if you use IE, don't count on ever correctly seeing a table again. Oh wait, you can't correctly see anything now.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  15. #15
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Yeah, IE makes writing web pages so hard. I think most people thing that it's right, and NS is wrong, but it's the other way around (generally )

Posting Permissions

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



Click Here to Expand Forum to Full Width