JavaScripts |
First posted Jun 2002 Last update Mar 15, 2015 |
E-mail hiding script, foils spam harvesting robots Popup window script for galleries as seen throughout CowboyFrank.net Webcam image refresh script, without reloading the entire page Expiring icon, goes away on a date you select Close a popup window by clicking on a link or image, like in my galleries Random image chooser as seen on my main index page |
Important Introductory InformationThe JavaScripts on this page assume you understand a bit about HTML (HyperText Markup Language). If you do not know how to work in HTML, it would be a very good idea to learn just a little bit about it. You don't have to learn a lot, just a little, then you can read all of it. I teach a course in Reading HTML. The entire course only takes one to two hours, depending on how many questions come up.HTML is the language of the web. It is simple to see the raw code behind a web page. In Internet Explorer, click View and Source. Looks like a lot of gibberish doesn't it? Believe me, it's not as complex as it seems, you just have to know a little bit about what you are looking at. Everything between the < > symbols (sometimes called angle brackets) is HTML coding which controls the formatting, background, fonts, colors, pictures, and links on the page. Here is a simple example. <A HREF="http://cowboyfrank.net">Click Here</A> for a link.
The "A" indicates this tag is going to be an "Anchor" tag, also called a link. There are about 30 or so tags available. Only about 10 are used extensively. It's that simple. Now of course there is more to it, such as style sheets, JavaScript, Embedded Objects, and so forth, but you don't really have to understand those to be able to read the coding behind a web page. One important thing to know about HTML. If the web browser comes across a tag it doesn't understand, the browser simply ignores it and goes on. However, if a piece of code is in the wrong place, or isn't properly formatted it can cause a real mess. I have a saying, "Real Webmasters Know HTM-hell". In other words, the coding can be simple or get very complex. Just look at my main index page for some rather complex coding. |
Pop up window JavaScriptIn memory of our friend Tom Williams.Tom was a Visual Basic programmer. He had never worked with JavaScript. In early May 2000, I asked him to try to help me improve a pop up window script I had been using for several years. Over a period of about 2 weeks, he purchased a reference book and learned the language. On May 26, 2000, Tom and his friend Bev, met us at Luray, Virginia for a Memorial Day weekend camping trip. On Friday I set up my notebook and a desktop computer on the picnic table. I networked the 2 machines together, and we started in earnest. The desktop had a number of older web browsers installed on it for trouble shooting. We spent about 5 hours together, he instructing me during the process. After 4 hours of fighting bugs in older browser versions, I made the decision to abandon error checking. Instead Tom constructed a script to redirect older browsers to a secondary file which did not use the JavaScript. That made everything much simpler. A few more adjustments and everything worked perfectly. We were all ecstatic. I have since had to abandon this redirect script, due to several issues with newer web browsers. There are three unique feature to this 'new window open' script.
After almost four years of tinkering, I finally had a script that did what I wanted. The next morning, after breakfast, Tom suffered a massive heart attack. At 1:38 pm, he was pronounced dead at the hospital. This is my memorial to a very dear friend. This part goes in your header
The Anchor Element
|
<A href="javascript:makeA('FileName','width','height')"><img src="frank.jpg" width="50" height="50"></A> |
FileName is the file to open. width is the width in pixels of the new window. height is the hight in pixels of the new window. Blue area is the text or thumbnail image which will become the Anchor, (the spot to click on). |
The anchor can be linked directly to the larger image but you will need to add about 20 or so pixels to the dimensions of the window over the size of the image due to the margin web browsers create on the top and left of the picture. Instead, I create a separate html file as follows with the larger picture in it. Note the style inside the body tag to eliminate the margin. |
<html> <head> <title>Cowboy Frank's Galleries</title> </head> <BODY STYLE="margin-left : 0px; margin-top : 0px;"> <img src="image.jpg" border="0" width="298" height="450" > </body> </html> |
Important suggestion for the popup script |
Webcam Refresh ScriptRefreshes the picture of your webcam without reloading the entire page.(Note: this script only works for one camera on a page. If you have mutable cameras you want to refresh on the same page try the script on this guy's site. CowboyScripts.org Simply copy this code and place it in your page where you want your webcam image to be. The only adjustments you need to make are
Caution: Make sure you don't introduce any extra carage returns in the long lines of this code or it might not work. |
<script language="javascript"> var refreshrate=6; //SECONDS BETWEEN REFRESH var image="WebCam1.jpg"; //IMAGE NAME var imgheight=240; //IMAGE HEIGHT var imgwidth=320; //IMAGE WIDTH function refresh(){ document.images["pic"].src=image+"?"+new Date(); setTimeout('refresh()', refreshrate*1000);} document.write('<IMG SRC="'+image+'" ALT="Alternate Text" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" STYLE="border: 1px solid Black;">'); if(document.images)window.onload=refresh; </script> |
Expiring NEW SignThis script will allow you to include a graphic next to a new item on your site and not have to worry about remembering to take it off.The script will show the graphic above until the date you select is past. Then the blank invisible graphic will take its place. Save these two images to the same directory as the script is used in. New graphic Blank graphic, (transparent gif) This part goes in your header
This part goes where you want the to appear
4/25/2005 is the last day to show the in the form of Month/Day/Year |
Close Window ScriptThis script is what I use in my galleries to allow the visitor to click on the picture to close the popup window. Note that you should not use this script in a regular page as it will cause the visitor to close your site. I only use it to close popup windows.This part goes in the header of your page
This part goes where you want the person to click to close the window.
|
Random Image ScriptDoes not work with FirefoxSelects a random image from a list each time the page is loaded. Note that the more images you include in your list the more random the appearence. I use to use this script on my home page but with the popularity of Firefox coming up and the fact the script doesn't work in Firefox I have changed to a server side include for those images.
This part goes in your header
This part goes where you want the images to show on your page.
|