Functions are great. You can store scripts in the head tag in functions (kind of like a storage locker for scripts you use and like) and call them from your page. This way you can reuse the same script again and again without having to type the whole thing in over and over and if you make changes you just change what is in the function and don't have to change all the individual scripts used on your page.
example>>> (calling a function to open a window)
What
the code looks like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>functions</title>
<SCRIPT LANGUAGE="javascript">
function popup() {
win1 = window.open('http://www.ebay.com','ebay','height=309,width=400,
left=0,top=235,resizable=no,scrollbars=no');
win1.focus();
}
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><a href="javascript:;popup();">link
that opens window and makes it focus (come
to front)</a>
<p><a href="javascript:;popup();">another
link that opens the same window and
makes it focus (come to front)</a></p>
<p><a href="javascript:;popup();">another
link that opens the same window and
makes it focus (come to front)</a></p>
</body>
</html>
*note: "win1" is a variable I use so I can adjust another property of this new window which is called "focus" or keeping it on top and active, as apposed to "blur" which means that it is not the currently active window.
Many ways to do it:
alternative script using an OnMouseDown handler
-with rollovers
-with 2 new pop-up windows that are sized and positioned.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>functions</title>
<SCRIPT LANGUAGE="javascript">
temp1=new Image();
temp1b=new Image();
temp1.src="thumb.jpg"
temp1b.src="thumb2.gif"
function popUpone() {
win1 = window.open('page1.html','mywindowname1','height=306,width=400,left=0,top=245,resizable=no,scrollbars=yes');
win1.focus();
win1b = window.open('page2.html','mywindow name 2','height=216,width=265,left=0,top=0,resizable=no,scrollbars=no');
win1b.focus();
}
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p><a href="#" script language="Javascript"
onMouseDown="popUpone();" onMouseOut="runme1.src=temp1.src"
onMouseOver="runme1.src=temp1b.src"><img src="thumbs/pro/senthum.jpg"
width="110" height="81" border="0" name="runme1"></a></p>
</body>
</html>