Quote:
|
I'm trying to make and install something that will change when I mouse-over it. Like a box that will open when I mouse-over it.
|
Easy work. You only need gifs/jpegs - ordinary images. One of the box closed, one of the box open. Then use the following code on your page (adapt it, or indeed ask for more help here)...
Code:
<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.getElementById("b1").src="b_blue.gif"
}
function mouseOut()
{
document.getElementById("b1").src="b_pink.gif"
}
</script>
</head>
<body>
<a href="http://www.w3schools.com" target="_blank" onmouseover="mouseOver()"
onmouseout="mouseOut()">
<img border="0" alt="Visit W3Schools!" src="b_pink.gif" id="b1" /></a>
</body>
</html>
http://www.w3schools.com/jsref/jsref_onmouseover.asp
You can simplify this further, i.e. use "short form"...
Code:
onmouseout="document.menu.src=pica.src" onmouseover="document.menu.src=picb.src"
is an example of the onmouse[etc] functions you can use inside the image tag itself, rather than in the <a href=""> tag which w3c has shown there since that would have been the original most normal basic standard long ago when I was knee high to a grasshopper's crap.
The other clever thing in my bit of code there (taken from a commercial site belonging to and built by me) is that it sticks the entire function into the onmouse[etc] rather than wasting energy, time and space with an actual subroutine* stuck into javascript tags.
(*The thing in javascript called 'function' it seems I have called a subroutine, who knows how interchangeable they are, it'd be a boring debate, but anyway, I apparently call most things subroutines if you go to them by name and run through a routine and return, whereas to me a function is something more like a single line equation using n's and an x and a y. eg on a scientific calculator)
Of course there are other bits of code elsewhere, largely just labels inside other tags, which cause document.menu000.src and pic1.src to mean something (i.e. refer to specific objects on the page).
To learn more about how to do all these sorts of things on a basic page look up or purchase some basic books on Javascript, a vital appendix-language adjoined to the world of html and much more obligatory than things like cascading style sheets which you can spend your life never using and still always be able to do everything you want, but NO ONE can do without Javascript. It's like water in a house. Bricks and carpets and electricity and cookers is all very well, but take away the water and you can't even flush the toilet.
__________________
I acknowledge Parker out of Thunderbirds and Glaxo Industries.
Last edited by hairygunther; 07-14-2009 at 05:58 AM..
|