Javascript Random Images (Full Version)

All Forums >> [Web Development] >> Accessibility



Message


rubyaim -> Javascript Random Images (8/25/2005 0:38:55)

Hello, I was wondering if using Javascript for random images would effect accessibility at all? Basically all I want to do is swap images on page load (the images are only for 'pretty' and not for content).

Have read through Creating Accessible JavaScript and think it will be okay if I use alt="", but am not 100% sure.

Have found some articles on doing this without Javascript, but they all use server side scripting and I'd rather keep this as html.

Thanks for any advice [:)]

Sally




Tailslide -> RE: Javascript Random Images (8/25/2005 3:19:12)

Hi Sally

As long as it's "just for pretty" stuff I'd say you're ok. I'd use the alt="" for images that that are structural for instance lines or bullets or for something that would generally be more confusing and annoying than enlightening for someone using a text reader.

I tend to include structural images in the CSS and they don't have any sort of Alt tag so I guess you're effectively doing the same thing. I've no idea what Alt="" will do to your validation if you do that though!




jaybee -> RE: Javascript Random Images (8/25/2005 5:48:52)

If you're using a <script> tag anywhere in your code you should also use a <noscript> tag for browsers without js.




rubyaim -> RE: Javascript Random Images (8/25/2005 19:06:05)

Tailslide, thanks for your input, it is much appreciated [:)]

It's company policy that all pages meet WAI-A at least. I generally don't find this too difficult but with things like this Javascript I sometimes get a bit confused.

The alt="" validates when tested outside of the Javascript, but at this stage my actual Javascript does not, am having trouble with the alt, height and width in the document.write [:(] Back to the drawing board I guess.

Jaybee, thanks - yes I always use <noscript>. It's easy to forget though so I added it to the Code Snippets in FrontPage a while ago.

Sally




Tailslide -> RE: Javascript Random Images (8/26/2005 3:03:09)

Sally

What exactly is it falling down on because I've got this sort of thing to work in the past at xhtml 1.0 strict?

I find that commenting the script out like this helps too (sorry if you're already doing it!):

<script type="text/javascript">
//<![CDATA[
document.write('blah blah')
 //]]>
</script>


Or if it's still causing you problems then can you remove the script itself to an external .js file?




rubyaim -> RE: Javascript Random Images (8/28/2005 19:49:51)

Hi - sorry for late reply - had a lovely 'computer free' weekend [:)]

I looked at this first thing this morning and realised straight away that I'd not put in "\" [8|]

So, the below is validating (XHTML 1.0 Transitional)

img width=\"80\" height=\"80\" alt=\"\" border=\"0\"

Thanks again for your advice [:)]

Sally




khai87 -> RE: Javascript Random Images (10/14/2005 21:13:37)

Hey there,

I just wanna know, if i want to include the the image and the links plus the text on that random image. How would the code be cos i know rank image plus link only, its like this

images[3] = "<a href = 'http://www.computerhope.com/history/newslet.htm'><img src='http://www.computerhope.com/banners/banner5.gif' alt='Computer Hope Newsletter'></a>";

i hope that you guys can help me on how to include the text after that random image and link.




rubyaim -> RE: Javascript Random Images (10/16/2005 19:12:26)

Hi, you should be able to include your text along with the image path and link like:

image[1]= "<a href=\"http://www.computerhope.com/history/newslet.htm\"> <img src=\"http://www.computerhope.com/banners/banner5.gif\" alt=\"Computer Hope Newsletter\"></a> <p>Here is some text.</p>"; 


Is that what you are after?




khai87 -> RE: Javascript Random Images (10/17/2005 6:47:34)

Alright, yeay. Thanks a million. I appreciate it!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.09375