Metachecker.net
|
FontsMadeEasy.com
|
RankChecker.net
Learn Java Script Today
|
Over 5000 Free Fonts
|
Tutorials
|
Javascript Forum
|
Other Javascript Resources
|
Cheat Sheet
JavaScript Basics
Inserting Javascript
Complete Tutorial
Advance DHTML Tutorial
Script archive
Advanced Tutorials
Alert Scripts
Animation
Audio
Background Effects
Banner Ads
Browser Window
Buttons
Button Forms
Calculcators
Calendars
Clocks & Dates
Cookies
Cursor Effects
DHMTL Games
DHTML Miscellaneous
Equivalents
Forms
Games
IE4+ Scripts
IE5+ Scripts
Image Effects
Image Miscellaneous
Links & Buttons
Math Related
Messages Miscellaneous
Miscellaneous
Mouse Tricks
Navigation
Page Details
Password Protection
Pulldown Menus
Random Stuff
Scrolling
Status Bar
Text Animation
User Detail
User Info
Window Control
DHTML Script - ChangeText
[View Sample]
This script changes text in a div when you mouseover the links. This script works in both 4.x browsers, 5.x browsers and degrades on lower browsers (nothing happens if a lower browser user mouseovers the links)
Insert into <HEAD>
<style type="text/css"> #divLinks{position:absolute; left:200; top:200; visibility:hidden} #divMessage{position:absolute; left:200; width:300; top:230; visibility:hidden} </style> <script type="text/javascript" language="JavaScript"> /******************************************************************************** Copyright (C) 1999 Thomas Brattli This script is made by and copyrighted to Thomas Brattli at www.bratta.com Visit for more great scripts. This may be used freely as long as this msg is intact! I will also appriciate any links you could give me. ********************************************************************************/ //Default browsercheck, added to all scripts! function checkBrowser(){ this.ver=navigator.appVersion this.dom=document.getElementById?1:0 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; this.ie4=(document.all && !this.dom)?1:0; this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; this.ns4=(document.layers && !this.dom)?1:0; this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) return this } bw=new checkBrowser() /*NOTE************************************************************************** Now works in IE4, IE5, NS4, NS5 and degrades for older browsers. BUG: On Gecko M9 there's a problem with the replaceNode command..Should work on the released version ********************************************************************************/ /**** Variables to set ****/ msgFont='Arial,helvetiva' //The font for the message msgFontSize=12 //Set the fontSize in px msgFontColor="Navy" //Set the fontColor //Set the text you want to display on mouseover here. messages=new Array() messages[0]="This is link nr 1, you should really visit it!" messages[1]="Link nr 2 (this one) is even better!" messages[2]="This link however, nr3, isn't that good" messages[3]="Maybe you should try this one?" messages[4]="Hello?" messages[5]="Later all.." messages[6]="" //This is the default text that appears when you mouse out /******************************************************************************** You don't have to change anything below this ********************************************************************************/ //Constructing the ChangeText object function makeChangeTextObj(obj){ this.css=bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0; this.writeref=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj].document:0; this.writeIt=b_writeIt; } function b_writeIt(text,num){ if(bw.ns4){ this.writeref.write(text) this.writeref.close() }else if(bw.dom){ this.writeref.replaceChild(document.createTextNode(messages[num]),this.writeref.childNodes[0]) }else if(bw.ie4) this.writeref.innerHTML=messages[num] } //The mouoseover function. Calls the objects writeIt method to write the text to the div. function changeText(num){ if(bw.bw) oMessage.writeIt('<span style="font-size:' +msgFontSize+'px; font-family:'+msgFont+'; color:'+msgFontColor+'">'+messages[num]+'</span>',num) } //The init function. Calls the object constructor and set some properties. function changeTextInit(){ if(bw.bw){ oMessage=new makeChangeTextObj('divMessage') oLinks=new makeChangeTextObj('divLinks') if(bw.dom || bw.ie4){ //Setting the style properties with(oMessage.writeref.style){fontFamily=msgFont; fontSize=msgFontSize; color=msgFontColor} } //Both layers are hidden by default to prevent users from mousing over them and creating errors while the page loads oMessage.css.visibility='visible' oLinks.css.visibility='visible' } } //Calls the init function on pageload. onload=changeTextInit </script>
Insert into <BODY>
<div id="divLinks"> <a href="#" onmouseover="changeText(0)" onMouseout="changeText(6,0)">Link 1</a> <a href="#" onmouseover="changeText(1)" onmouseout="changeText(6,1)">Link 2</a> <a href="#" onmouseover="changeText(2)" onmouseout="changeText(6,2)">Link 3</a> <a href="#" onmouseover="changeText(3)" onmouseout="changeText(6,3)">Link 4</a> <a href="#" onmouseover="changeText(4)" onmouseout="changeText(6,4)">Link 5</a> <a href="#" onmouseover="changeText(5)" onmouseout="changeText(6,5)">Link 6</a> </div> <div id="divMessage"> Just place the default text here (this will show always in 3.x browsers) You have to place this with tables or something instead of layers for backwards compatibility. </div> YOUR REGULAR BODY CONTENT GOES IN HERE
Other Options