12 web design hours

Javascript

Javascript Quickees

-

Referenced from
http://webmonkey.wired.com

 

Cut-and-Paste Javascript

I am going to give you a few scripts that you can just copy and paste into the code and have them work. I will try to give you the best example I can to help you use the code.


Close Window Script

<A HREF="index.html" onclick="window.close()"> Close Window</A>

All you have to do is paste this script into an new broswer window and when you display it, you can close the open browser window.

[ Click to open new browser window and see this script in action]

^ Top


Dropdown Menu with links

<FORM action="" method=POST name=ALnav>

<SELECT name=scripts>
<option>--- Select Topic---
<option value="http://www.athinker.com">Link to Athinker.com
<option value="http://webmonkey.wired.com/webmonkey/index.html">Link to Webmonkey
<OPTION>------
<option value="index.htm">&gt; HOME Textbook

</SELECT>

<INPUT type=button name=Button value="Go!" onClick="window.location=document.ALnav.scripts.options[document.ALnav.scripts.selectedIndex].value;">

</FORM>

[See the script in action below]

Javascript Image Rollover

Goes in the Head code of the page

<script language="Javascript">
<!--
//Slide Show script (this notice must stay intact)
//For this and more scripts
//visit java-scripts.net or http://wsabstract.com

if (document.images) {
button1 = new Image
button2 = new Image

button1.src = 'img1.gif'
button2.src = 'img2.gif'
}
//-->
</script>

In the Body of the page:

<a href="http://java-scripts.net" onmouseover="document.rollover.src=button2.src" onmouseout="document.rollover.src=button1.src"><img src="img1.gif" border=0 name="rollover"></a>

Playing with stylesheets