Here are some helpful Java Scripts
![]()
To hide your Javascripts
Move the code from the HEAD section of your document into its own file and
save it with a .js extension. Add the following
in the head section <.script language="_JavaScript"src="filename.js"><./script>
where filename.js is the name of your file. You must make sure that the
_JavaScript file DOESN'T include the
SCRIPT tags. Now put a reference to the location of the .js file.
2. A very basic tutorial: http://www.javascriptkit.com/javatutors/external.shtml
This tutorial is pretty wordy but is also a little more in depth:
http://www.htmlgoodies.com/beyond/extjs.html
![]()
Here is a simple javascript to hide your E-mail address from the spam robots. Here is how it works:
<script language="Javascript">
<!--
//this simple script by a1javascripts.com
//please leave credit and instructions intact
//simply enter your emailname and emailserver below
//and copy and paste to entire script where you want it to show.
emailname = "kris"
emailserver = "yahoo.com"
//change the font face, color and size below
document.write("<font face='Arial,Helvetica' size=-1>");
document.write("<a href='mailto:" + emailname + "@" + emailserver + "'>");
document.write("<font color='ff0000'>");
document.write(emailname + "@" + emailserver);
document.write("</a>");
document.write("</font>");
//-->
</script>
![]()
<A HREF="http://javascript.internet.com/page-details/bookmark-us.html">
http://javascript.internet.com/page-details/bookmark-us.html</A>
The above link will allow you to copy a Java Script called 'Bookmark Us'. This neat little script will allow IE users to automatically add your site link to their bookmarks.
![]()
To disallow your site from being displayed in someone else's frames, put the following code into your frameset document or in the head of all your pages in a non-framed environment:
if (top != self) {
top.location = location
}
<script language="JavaScript">
<!--
var pages_loaded = 0;
var framed = false;
if (location.href!=top.location.href) {
top.location.href=location.href;
framed=true;
}
![]()
Another Java script for the same thing:
Place a
link on your main page to repost your main page as the "parent frame"...<A HREF="your site url" TARGET="_parent"> Click here to break free of previous frame </A>
NOTE you must type the underscore before the word "parent"...
![]()
Javascript for a pop up window
This goes in the head section of your page. You can decide on
where you want the window to pop up as well as whether you want scrollbars,
toolbars, menubars or status bars. A no is the number zero and yes is a number
one ( 0 or 1 ). On this particular script there is no toolbar, there is a
scrollbar and a statusbar but no menubar. The window is not resizable. The
window is 600px wide and 400px long and opens 80 pixels down from the top and
100 in from the left.
<!-- START OF SCRIPT -->
<script LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "',
'toolbars=0,
scrollbars=1, location=0, statusbars=1, menubars=0, resizable=0, width=600,
height=400, left = 100, top = 80');");
}
// End -->
</script>
![]()
This code snippet must be between your
beginning and ending script tags.
A javascript to collect E-mail addresses for a news letter <CENTER> <FORM METHOD="post" ACTION="mailtoyourname@domain.com?subject=Button Click"> <INPUT TYPE="submit" VALUE="Click Me!"> </FORM> </CENTER>
![]()
To stop (or at least slow down) right click thieves:
<script language
="JavaScript"> <!--// No rightclick script
var message="Sorry, that function is disabled. All contents © Stewrat Enterprises." // Message for the alert box
function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// -->
</script>![]()
This code gives the date.
<DIV ALIGN="CENTER">
<H5><SCRIPT LANGUAGE="JavaScript">
<!-- Begin
today=new Date();
day=today.getDate();
year=today.getFullYear();
month=today.getMonth()+1;
if (day==1) end=("st");
else if (day==2) end=("nd");
else if (day==3) end=("rd");
else if (day==21) end=("st");
else if (day==22) end=("nd");
else if (day==23) end=("rd");
else if (day==31) end=("st");
else end=("th");
if (month==1) name=("January");
else if (month==2) name=("February");
else if (month==3) name=("March");
else if (month==4) name=("April");
else if (month==5) name=("May");
else if (month==6) name=("June");
else if (month==7) name=("July");
else if (month==8) name=("August");
else if (month==9) name=("September");
else if (month==10) name=("October");
else if (month==11) name=("November");
else name=("December");
document.write("<B>Today is " + name + " " + day + end + ", " + year + "</B><BR>");
// End --></script>
</h5>
</DIV>
![]()
T
Using JavaScript to rotate your images.
-----------------------------
PASTE IN THE DOCUMENT HEAD:
-----------------------------
<script language="JavaScript"
type="text/javascript">
<!-- hide this script from tired old browsers
// pix rotate
number_of_pix=4;
var sctr=0;
var halt=0;
var isn=new Array();
for (i=0;i<number_of_pix;i++){
isn[i]=new Image();
}
isn[0].src="images/h_anim_1.jpg";
isn[1].src="images/h_anim_2.jpg";
isn[2].src="images/h_anim_3.jpg";
isn[3].src="images/h_anim_4.jpg";
function rotateIt(){
if (halt!=1){
sctr++;
if (sctr>number_of_pix-1){
sctr=0;
}
document.pix.src=isn[sctr].src;
setTimeout("rotateIt()",2000);
}
}// End Hiding -->
</script>
-----------------------------
PASTE ANYWHERE IN THE BODY:
-----------------------
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide JavaScript from Java-Impaired Browsers
sctr=0;
rotateIt();
// End Hiding -->
</SCRIPT>
-----------------------------
IMAGE NAME CALLS THE JS, EG:
-----------------------------
<img name="pix" src="images/h_anim_1.jpg"
alt="" width="220"
height="135" border="0">
-----------------------------
![]()
<script language
="JavaScript"><!-- hide from JavaScript-challenged browsers
function openWindow_demo(myURL, myName, myWidth, myHeight) {
var useWidth = 475;
var useHeight = 570;
if (myWidth != '') {useWidth = myWidth;}
if (myHeight != '') {useHeight = myHeight;}
var attrs = "width=" + useWidth + ",height=" + useHeight + ",scrollbars=yes,screenx=50,screeny=50";
popupWin = window.open(myURL, myName, attrs)
}
// done hiding -->
</script>
![]()
<script language
="JavaScript"><!-- hide from JavaScript-challenged browsers
function openWindow_help(url, name) {
popupWin = window.open(url, name, 'width=450,height=300,scrollbars=yes,screenx=50,screeny=50');
popupWin.focus();
}
// done hiding -->
</script>
![]()
Here are some more helpful sites:
http://www.geocities.com/~jsmaster/
http://www.javascript-page.com/
CookieCentral
- Javascript demos of setting cookies
Dynamic Drive DHTML code
library
The JavaScript Source -
a Cut & Paste Javascript library.
Web Design Clinic
Web
Source Javascript Snippets
WebMonkey
- Javascript Code Library
Automatic Timed Self-Closing Popup Window
Easy
Instant Interactive Menu Links
![]()
Light 'Em Up Multi-Color Interactive Mouse-Over Links
Dirt-Simple Four-State Mouse-Interactive Image Buttons
Cross-Browser JavaScript SlideShow -
Cross-Browser JavaScript SlideShow.
Make This Page Your Homepage Script
Basic
No-Right-Click Script with Alert Box
![]()
TriState
Rainbow Color Link Script
![]()
Tristate Rainbow Scrollbar I - All Scrollbars -
Change Scrollbar Colors Dynamically
E-mail
Address Checker-Validator
![]()
Dynamic Title Bar Date-Time Clock
Boogey-Down Glow-And-Jump Animated 3-Color Neon Text
Active
Tri-State Roll-Over Images on Form Submit and Reset![]()
Automatic
E-mail This Link Script with Auto-Capture and Validation
![]()
Javascript for the World Wide Web
JavaScript
Cookie Calendar
This calendar, written entirely in JavaScript, uses cookies to allow users to
save information on specific dates. Includes daily and monthly summaries and a
complete help file. Cookie Calendar works as its own
program as well. Great!