I am teaching an elementary school this coming semester, and have created an explorer of animals and birds using javascript, and also using a flash created html code that shows a small picture of various animals and when they go onMouseOver it opens a new window with a larger picture that also makes the sound the animal or bird makes, and
when they move their mouse off, the sound stops and the larger picture goes away. I'm hardly an expert at this but it is really working exactly as I want it to but the entire code is quite lengthy because I do not know how to pass the flash created HTML to javascript as a parameter, and thus must have a javascript containing the HTML for each and every object. In this small example you will see that I have to create each of these javascripts for each animal or bird and then individually number the functions MakeNewWindow and CloseNew Window for each object. It would be nice if I knew how to pass the flash code as a parameter, rather than have to create a new javascript code for each object. I could then just have one javacode in the head and pass the flash created HTML to it, and not have to bother with a huge number of javascripts, each having to have separately numbered makeNewWindow and closeNewWindow functions.
This is the javascript and HTML which calls that javascript for the two objects "cow" and "duck" for example. Obviously it won't work as shown, but it clearly demonstrates my problem and why I would want to pass the flash HTML as a parameter rather than have a javascript for each object.
Please understand I am not a professional in this, but I am sure even if I can't reduce the code, the kids will love it. Hope someone can help... in any case... thanks for looking...
---------------------------------------------------------
<html>
<head>
</head>
<body>
<div align="justify"><B>duck</B> <I>n.</I> ---
<script type="text/javascript">
var newWindow;
function makeNewWindow ( ) {
newWindow=window.open("","","height=500,width=600,left=0");
newWindow.location.href="duck.html";
}
function closeNewWindow( ) {
if (newWindow) {
newWindow.close();
newWindow = null;
}
}
</script>
<img src=duck.jpg "height=80 width=80" onMouseOver="makeNewWindow()"
onMouseOut="closeNewWindow()"/><br>
<div align="justify"><B>cow</B> <I>n.</I> ---
<script type="text/javascript">
var newWindow;
function makeNewWindow1 ( ) {
newWindow=window.open("","","height=500,width=600,left=0");
newWindow.location.href="cow.html";
}
function closeNewWindow1( ) {
if (newWindow) {
newWindow.close();
newWindow = null;
}
}
</script>
<img src=cow.jpg "height=80 width=80" onMouseOver="makeNewWindow1()"
onMouseOut="closeNewWindow1()"/><br>
</body>
</head>
--------------------------------------------------
You see that the first half is for a duck and the second half is for a cow.