JavaScripts |
First posted Jun 2002 Last update Dec 20, 2009 |
|
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 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 allot, 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. |
Hiding your E-mail From The SpamersA few years ago someone in the spaming industry came up with a program that searches through web pages looking for e-mail addresses. When turned loose these "e-mail harvesting robots" look through your web page seeking out the "mailto:" coding tag that is used to start an e-mail anchor. It also looks for the familiar @ symbol which is generally used only for e-mail address. When it finds yours it will add you to their spam list. The most common sourse by far for spam lists are e-mail addresses exposed on web pages. The second most common source are e-mails with lots of other people's e-mail addresses showing. If you send an e-mail to a number of people, use Blind Carbon Copy to hide other's addresses.
A very interesting study on spam and it's sources can be found at
A simple method of hiding your address from the harvesters It is easy to hide your e-mail address by replacing the dot and @ symbol with html code equivalents. You must be editing the raw html code of your page to do these modifications. You can not simply enter these codes in a graphical web editor like FrontPage, DreamWeaver or an online website builder. Check your editor's menus for an option to insert JavaScript or html code.
Here's a simple to use converter that generates the above code for what ever e-mail address you enter. This script does not submit your email address to me, it just converts some of the charters to html equivalents. Copy the result from the lower box and paste it into your html page editor's JavaScript or html code inserting option. You may notice I have also included an additional converted charter (the "m" in mailto) just to add an extra level of confusion for the spam harvesters.
A more advanced system which I use to use but began abandoning in 2008 because some newer web browsers wouldn't display the script. This is a script designed by a friend of mine. This part goes in the header of your page
This part goes where your e-mail will be on the page
| ||||||||
| <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 aThe 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. This part goes in your header
This part goes where you want the
4/25/2005 is the last day to show the |
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.
|