Script works in Mozilla but not IE6 (latest versions)?

M

mark

Hi i get an error on this line of my script. It works in mozilla but not IE6

Here is the error message

document[...] is null or not an object

Here is the function - also images for this button rollover are preloaded

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--

function roll(img_name, img_src)
{
document[img_name].src = img_src;
}

//-->
</SCRIPT>

call function with this

onmouseover="roll('sub_but1', 'http://www.kidsoft.org.uk/buttons/home1a.gif')"
onmouseout="roll('sub_but1', 'http://www.kidsoft.org.uk/buttons/home1.gif')"

Any ideas or subtle pointers

many thanks
 
M

Michael Winter

[snip]
<SCRIPT LANGUAGE="JAVASCRIPT">

The language attribute has been deprecated for over six years. Use the
(required) type attribute instead:


Hiding scripts like that is also an out-dated practice.
function roll(img_name, img_src)
{
document[img_name].src = img_src;

There is no reason for a named image to be a property of the document
object. Images have their own collection, images, so it's best to use that:

document.images[img_name].src = img_src;

[snip]
onmouseover="roll('sub_but1',
'http://www.kidsoft.org.uk/buttons/home1a.gif')"
onmouseout="roll('sub_but1',
'http://www.kidsoft.org.uk/buttons/home1.gif')"

That's a very cumbersome way to perform rollovers.
Any ideas or subtle pointers

Have a look at <URL:http://www.mlwinter.pwp.blueyonder.co.uk/image-swap/>.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top