Import Javascript effect into html body

V

Viabug123

I have an effect of changing images in javascript. When mouse over
image1, it changes to image2.
But I don't know how to import the above javascript effect in the body
of html, so that I can design the html page. There is no function of
<body onmouseover="function();...>. Could anyone suggest me any ideas
to solve it? Thanks a lot.


onMouseOver="handlePress();return true;"
onMouseUp="handleRelease();return true;"
....
if (document.images) {
img_on =new Image(); img_on.src ="image/1.gif";
img_off=new Image(); img_off.src="image/2.gif";
}

function handlePress() {
if (document.images) document.imgName.src=img_on.src;
}

function handleRelease() {
if (document.images) document.imgName.src=img_off.src;
}
 
N

Neredbojias

I have an effect of changing images in javascript. When mouse over
image1, it changes to image2.

Do you want it to change back to image1 when you mouseout? If so, you
could use just css.
But I don't know how to import the above javascript effect in the body
of html, so that I can design the html page. There is no function of
<body onmouseover="function();...>. Could anyone suggest me any ideas
to solve it? Thanks a lot.

Your javascript examples were very old and outdated. Best check with the
newsgroup "comp.lang.javascript" for advice. What you want to do is
actually pretty simple but you need to know something about the current
DOM.
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top