|
-
May 25th, 2002, 01:31 PM
#1
Thread Starter
Addicted Member
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
-
May 25th, 2002, 02:30 PM
#2
Stuck in the 80s
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.
-
May 25th, 2002, 02:33 PM
#3
Stuck in the 80s
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...
-
May 25th, 2002, 03:19 PM
#4
Frenzied Member
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.
-
May 25th, 2002, 04:49 PM
#5
PowerPoster
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
-
May 25th, 2002, 05:23 PM
#6
Frenzied Member
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.
-
May 25th, 2002, 05:25 PM
#7
Frenzied Member
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
-
May 25th, 2002, 11:20 PM
#8
Stuck in the 80s
Now that's wack...
-
May 27th, 2002, 03:38 AM
#9
Fanatic Member
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
-
May 27th, 2002, 07:36 AM
#10
Frenzied Member
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?
-
May 27th, 2002, 08:04 AM
#11
Fanatic Member
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
-
May 27th, 2002, 09:45 AM
#12
Frenzied Member
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
-
May 28th, 2002, 10:58 AM
#13
Black Cat
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.
-
May 28th, 2002, 02:34 PM
#14
Frenzied Member
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.
-
May 28th, 2002, 05:13 PM
#15
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|