Java Code Samples

I do not claim to be an expert Java programmer, but I have collected a number of Java scripts and use them in many of the web sites I design.

E-mail hiding script, foils spam harvesting robots
Random Banner Rotator

E-mail Hiding Script

The term "e-mail harvesting robot" means a process where someone can visit a web site or many websites looking for a "mailto:" tag that is used to start an email anchor. It also looks for the famnilir @ sysmbol which is used in email addresses. When these conditions are met, it graby your email address and addes it to their spam list.

Here is a script designed which will hide your address from the robots but still allows it to work in a visitors web browser.

<SCRIPT language=JavaScript>
function escramble(z,x)
var h='</a>'
var b='lto:'
var d='@'
var f='\">'
var a='<a href=\"mai'

Banner Rotator

This script is used on our main page to rotate banners. This gives our site a new look and feel each time someone visits out site.

<SCRIPT language=JavaScript>
banners = new Array()
banners[0]="<IMG BORDER=0 SRC=images/banner01.JPG alt='Some title text'>"
banners[1]="<IMG BORDER=0 SRC=images/banner02.JPG>"
banners[2]="<IMG BORDER=0 SRC=images/banner03.JPG>"
banners[3]="<IMG BORDER=0 SRC=images/banner04.JPG>"
banners[4]="<IMG BORDER=0 SRC=images/banner05.JPG>"
banners[5]="<IMG BORDER=0 SRC=images/banner06.JPG>"
banners[6]="<IMG BORDER=0 SRC=images/banner07.JPG>"
var Number = Math.round(Math.random()*6);
var TheImage = banners[Number]
document.write("<CENTER>" +TheImage+ "</center>")

Notice the line that contains the Math statement. In our example we are rotating 7 banners as noted by the number 6. This number must always be the total number of banners minus 1.

Back to Main Page

© copyright (1995-2009) Alpine Software. All rights Reserved.

last update: 04/01/2013, 10:33:54