An Algorithmic and Social Introduction to Computer Science (CSC-105 2000S)

Find a useful JavaScript script on the Web. Report on the source and how you might use that script.



I think that the script for making images change when the mouse pointer goes over them is pretty neat. Perhaps not the most useful thing one could do with JavaScript, but it can help users to know what a button does before they click it, which seems somewhat useful. This script uses the "onmouseout" and "onmouseover" commands to tell the page what image to show depending on where the mouse is. An example of this script is on the Grinnell College Career Development homepage, at


wow! this is so much fun! so i've copied the javascript for a clock that tells you the time all around the world onto my page, but i don't know how to make it public from anywhere else but mathlan (which is somewhere i'm not planning on being until 10am tomorrow morning). can you please teach us how to do that?

[If you can use an ftp program on your computer (Fetch on the Mac, I'm not sure what it's called in the PC world), you can upload files to your MathLan account. It's also possible to put Web pages on storageserver, but I'll admit that I don't know the approved procedure.]

so i found the clock useful because i like having the time in front of me when i'm working on a computer. usually this is not a problem because all the macs and pcs on this campus have it in the status bar. in mathlan, however, this is not the case. for whatever reason, the time is not displayed anywhere i can tell on the desktop so it would be nice to have it accessible on my webpage. [If you look in the lower-left corner of the desktop, you should see a nice little analog clock.] also, since i attend school half way across the country from where i live, whoever checks my page can see what time it is where i am, compared to where they are, including friends, parents, etc.

i don't know if that answers your question. i would use the script by putting it on my page. i'm going to edit though, and only leave the areas that are relevant to me. otherwise there is this huge long list.

[I'd like to know where you found the script.]


I decided that today I liked the idea of having an e-mail button on a website. I think it is a nice way to give users access to the individual behind the webpage, despite the website's criticism that this function is overused. I rather think pop-up advertisements are overused more. I just think it is a really good idea to give people contact options, as this is a large part of the internet's purpose, and it can be a useful function for numerous personal and business related webpages to induce feedback from users.

Free JavaScripts provided
by The JavaScript Source

Here is the code from The JavaScript Source!!

<!-- STEP ONE: Copy this code into the BODY of your HTML document -->


<!-- This script and many more are available free online at --> <!-- The JavaScript Source!! -->

<FORM> <INPUT TYPE="button" VALUE="Click Here to Write to Me" onClick="parent.location=''"> </FORM>

<FORM> <INPUT TYPE="button" VALUE="Click Here to Write to Me - Subject Predetermined" onClick="parent.location=' Subject"> </FORM>

<p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="">The JavaScript Source</a></font> </center><p>

<!-- Script Size: 0.70 KB -->



Please don't take the following answer to the daily question as a joke. This is a website that I have known about for a longtime and I know that a lot of people have visited this site over the years. I never understood the attraction to the website and wanted to investigate it. I still don't have all the answers, but I feel that by analyzing the JavaScript I have a greater understanding behind the workings of the website.

is a useful website because it is an irregular site showing the possibilities of the internet and it is fun to look at. The script is fairly simple mostly consisting of images. is not as useful as Yahoo! or the NYTimes but there are many different websites that fulfill many different purposes. fulfills its role of comic relief. The script itself is relatively simple. The main use it to present images to the user. In this case the images move (dance).

At the top of the script I noticed a definition of some keywords (content="hamster, dance, ... Is this a list of keywords, that if searched on a search engine (Yahoo, Lycos, etc.), would appear as a result of the search? [Yes] Also, the script is different for Netscape and Microsoft Explorer. This allows the website to optimally appear on the screen of the user regardless of the viewer being used.

At the beginning and end of the script, corresponding to the top and bottom of the webpage, advertisements are inserted with links to other sites. For a popular website, this brings in needed money, allowing the website to remain free. A great example of this is the New York Times. To receive a paper subscription is costs $.50 a day, and more on Sundays, while the most, if not the entire paper, of the paper is on the internet for free. The advertising on the webpages allows this service to be free. It costs relatively little for the NYTimes to be on the web and the advertising costs easily cover those costs.

A criticism of JavaScript demonstrated by the website is that to insert each image the complete text must be stated. It would seem to be more efficient if there was a repeat function:

<IMG src="The Hampster Dance_files/hamu.gif"> [enter][repeat step 20 times]

[In fact, there is a repeat function in JavaScript. It is possible that the author used it and that there is no longer evidence of such.]

Then a repeat function allows the programmer to write the same amount in less time and makes the program code more concise. This might decrease the amount of time it takes to download a website if the computer knows to repeat a function rather than determining the output of a function and then returning a different result.

[Note that the only part of the script left in the document is as follows.]

<SCRIPT language=javascript><!-- if ( navigator.appName == 'Netscape' ) { document.write( '<embed src = "originaldedodedo.wav" autostart="true" hidden="true" loop="true" ></embed>' ); } else if ( navigator.appName == 'Microsoft Internet Explorer' ) { document.write( '<bgsound src = "originaldedodedo.wav" loop="-1">' ); } else document.write( '<bgsound src = "originaldedodedo.wav" loop="-1"><embed src = "originaldedodedo.wav" autostart="true" hidden="true" loop="true" ></embed>' );

//--> </SCRIPT>


here's the web page with java script:

i couldn't copy the script from the page source so that's why it's not here. the page was pretty neat, though, it was a guessing game and i just had to hit a number and it would register and tell me if i guessed right or not. i think this is really useful because you can just type something without clicking on a box and entering the answer in a specific place on the page.

[I wasn't able to get it to work, but I did note that you can find portions of the script at]


This source can be found at This script in particular is used for sports fans who are looking at the day's MLB preseason scores can look around the world of sports and find other things of interest to them. This can be extremely useful on many sites, giving the reader the opportunity to move around by merely clicking the menu and clicking on the topic they wish to read about. If the topics were cross stitch and weaving instead of minor league baseball and boxing, this kind of menu would be equally relevant.

<form name="menu" onsubmit="gotosite(document.forms[0].url.options[document.forms[0].url.selecte dIndex].value);return false"> <select name="url" onchange="gotosite(this.options[this.selectedIndex].value)"> <option selected>More Sports <option value="/auto/index.html">Auto racing <option value="/minorlbb/index.html">Baseball-min. <option value="/boxing/index.html">Boxing <option value="/cfl/index.html">CFL <option value="/nch/index.html">Col hockey <option value="/extreme/index.html">Extreme <option value="/skating/index.html">Fig. skating <option value="/minorlh/index.html">Hockey-min. <option value="/horse/index.html">Horse racing <option value="/outdoors/index.html">Outdoors <option value="/wnba/index.html">WNBA <option value="/moresports/index.html">Other sports </select><noscript><input type="Submit" value="GO" onsubmit="gotosite(document.forms[0].url.options[document.forms[0].url.selecte dIndex].value);return false"></noscript></form>



This Javascript program is from The JavaScript" It is a website that is primarily for downloading Javascript programs, and it has a huge library. The program is for a time converter: a program that can convert minutes into seconds, seconds into hours, etc. I'm not sure about the everyday use for this program for me personally, but I'm sure there is some job out there where such a program would be useful regularly. Anyway, its an interesting way to pass the time, so to speak.


<SCRIPT LANGUAGE="JavaScript"> <!-- Original: Ryan Sokol --> <!-- Modified: Ronnie T. Moore, Editor --> <!-- Web Site: The JavaScript Source -->

<!-- Begin function checkInt(str) { if (!str) return 0; var ok = ""; for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i+1); if (ch < "0" || "9" < ch) { alert("Only integer input is allowed!\n\n" + parseInt(ok) + " will be used because '" + str + "' is invalid.\nYou may correct " + "this entry and try again."); return parseInt(ok); } else ok += ch; } return parseInt(str); }

function checkDecimal(str) { if (!str) return 0; var ok = ""; for (var i = 0; i < str.length; i++) { var ch = str.substring(i, i+1); if ((ch < "0" || "9" < ch) && ch != '.') { alert("Only numeric input is allowed!\n\n" + parseFloat(ok) + " will be used because '" + str + "' is invalid.\nYou may correct " + "this entry and try again."); return parseFloat(ok); } else ok += ch; } return str; }

function makeHours(form) { hour = (checkInt(form.hour.value)); // validates input min = (checkInt(form.min.value)); // sets invalid input to 0 sec = (checkInt(form.sec.value)); return (hour + min/60 + sec/3600); }

function makeTime(form) { num = (checkDecimal(form.hourtotal.value)); // validates input if (num) { form.hour.value = parseInt(num); num -= parseInt(num); num *= 60; form.min.value = parseInt(num); num -= parseInt(num); num *= 60; form.sec.value = parseInt(num); } } // End --> </script> </HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->


<center> <form name="timeconverter"> <table border=1> <tr> <td>Time:</td> <td> <input type=text name=hour size=3 maxlength=3> Hours<br> <input type=text name=min size=3 maxlength=3> Minutes<br> <input type=text name=sec size=3 maxlength=3> Seconds </td> </tr>

<tr> <td>Hours:</td> <td> <input type=text name=hourtotal size=10> </td> </tr>

<tr> <td colspan=2 align=center> <input type=button nametoHours value="Time to Hours" onClick="this.form.hourtotal.value=makeHours(this.form);"> <br> <input type=button name=toTime value="Hours to Time" onClick="makeTime(this.form);"> </td> </tr> </table> </form> </center>

<p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="">The JavaScript Source</a></font> </center><p>

<!-- Script Size: 2.61 KB -->

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Wed Feb 16 08:16:00 2000.

This page generated on Wed Mar 15 09:19:01 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at