PDA

View Full Version : wierd question



IanMarlowe
07-24-2005, 07:14 AM
I was wondering, and after much try have failed. Can you make a mouseover affect so the word (for example):

LEARN HTML

(which would be a hyperlink)

would be changed to:

LEARN HTML NOW!

?

Could you do that? It would basicallt be adding a bit of text. These are some of the ways I tried (all useless):



<script type="text/javascript">
document.write('<a href="blah.html">Hyperlink</a>
onMouseover
document.write('<a href="blah.html">Hyperlink to blah</a>
</script>

that code prooved useless...



<script type="text/javascript">
"extra"=to blah //variable
document.write('<a href="blah.html">Hyperlink</a>')
onMouseover
document.write(extra) + ('<a href="blah.html">Hyperlink</a>')
</script>

as did that one...

Any Ideas?

jscheuer1
07-24-2005, 11:19 AM
One thing, once the document is parsed (loaded), invoking document.write produces what amounts to a new document, wiping out the current one. So, you need a different method. For something like this, the innerHTML property will serve:

<a href="htmltutorial.htm" onmouseover="this.innerHTML='LEARN HTML NOW!'" onmouseout="this.innerHTML='Learn HTML'">Learn HTML</a>