Μέτρηση των παραγράφων σε ένα HTML έγγραφο
<HTML>
<HEAD>
<TITLE>
Παράδειγμα Πρώτο
</TITLE>
</HEAD>
<BODY>
<P> Αυτό το παράδειγμα παρουσιάζει συλλογές στην DHTML
<P> Υπάρχουν 4 παράγραφοι σ’αυτό το έγγραφο
<P> Χρησιμοποιούμε την tags() μέθοδο για να επιστρέψουμε μια συλλογή
<P>Χρησιμοποιούμε την ιδιότητα Length για να μετρήσουμε τις παραγράφους
<SCRIPT language= «JavaScript»>
var prgaphs = document.all.tags («P»)
var numpgraps = pgraphs.lenght;
alert (numpgraps + « total paragraphs » );
</SCRIPT>
</BODY>
</HTML>

Βασικές ιδιότητες στην πράξη
<HTML>
<HEAD>
<TITLE>
Παράδειγμα Δεύτερο
</TITLE>
</HEAD>
<BODY>
<P id=para left=100 top=100>
Βασικές ιδιότητες στοιχείων στην JavaScript
<SCRIPT language = «JavaScript»>
var pgraph = document.all.tags(«P»).item(0);
document.write(«<P>id : » + pgrah.id);
document.write(«<P>tagname : » + pgraph.tagName );
document.write(« <P>top :» +pgraph.top);
document.write(«<P>left : » + pgraph.left );
</SCRIPT>
</BODY>
</HTML>

Αλλαγή του στυλ της γραμματοσειράς με DHTML
<HTML>
<HEAD>
<TITLE> Changing the Font Family </ TITLE>
</ HEAD>
<SCRIPT LANGUAGE = ‘‘JavaScript’’>
function mytext_onmouseover( ) {
mytext.style.fontFamily = ‘‘serif ’’;
}
function mytext_onmouseout ( ) {
mytext.style.fontFamily = ‘‘sans.serif ’’ ;
}
< / SCRIPT >
<DIV id = mytext style = ‘‘font.family : serif ; font-size: 16pt’’
onmouseover = ‘‘mytext_onmouseover ( ) ’’
onmouseout = ‘‘mytext_onmouseout ( ) ’’ >
Flipping between serif and sans-serif faces.
< /DIV>
< /BODY>
< /HTML>

Αλλαγή του μεγέθους της γραμματοσειράς με DHTML
<HTML>
<HEAD>
<TITLE> Font SizeChanges < / TITLE >
< /HEAD>
<SCRIPT LANGUAGE = ‘‘JavaScript’’>
function mytext_onmouseover ( ) {
mytext.style.fontSize = ‘‘5’’ ;
}
function mytext_onmouseout ( ) {
mytext.style.fontSize = ‘‘2’’ ;
}
< /SCRIPT>
<DIV id = mytex STYLE=‘‘font-size=2; color=blue;
font-family=sans.serif’’
onmouseover = ‘‘mytext_onmouseover ( ) ;’’
onmouseout = ‘‘mytext_onmouseout ( ) ;’’>
This is a Dynamic Size Change !
< /DIV>
< /BODY>
< /HTML>

Αλλαγή του χρώματος της γραμματοσειράςμε DHTML
<HTML>
<HEAD>
<TITLE>Color Changes< / TITLE>
< /HEAD>
<SCRIPT LANGUAGE = ‘‘JavaScript’’>
function mytext_onmouseover ( ) {
mytext.style.color = ‘‘red’’ ;
}
function mytext_onmouseout ( ) {
mytext.style.color = ‘‘red’’
}
< /SCRIPT>
<H2 id = ‘‘mytext’’ style = ‘‘color : blue ; font-family : sans-serif’’
onmouseover = ‘‘mytext_onmouseover ( ) ;’’
onmouseout = ‘‘mytext_onmouseout ( ) ;’’>
This is a Dynamic Color Change !< / H2>
< / BODY >
< /HTML >

Κρύψιμο εικόνας με DHTML
<HTML>
<HEAD>
<TITLE>Color Changes< /TITLE>
< / HEAD>
<BODY>
<SCRIPT LANGUAGE = ‘‘JavaScript’’>
function picture_onmouseover ( ) {
picture.style.visibility = ‘‘hidden’’ ;
}
.function picture_onmouseout( ) {
picture.style.visibility = ‘‘visible’’ ;
}
< / SCRIPT>
<DIV STYLE = ‘‘color = blue ; font-family=sans-serif ;’’
onmouseover = ‘‘picture_onmouseover ( ) ;’’
onmouseout = ‘‘picture_onmouseout ( ) ;’’>
Pass over the text , and watch me disappear !
< / DIV>
<P>
<IMG ID = picture src = ‘‘picture.gif’’ visibility = ‘‘visible’’>
< / BODY>
< / HTML>

Ολίσθηση με DHTML
<script>
<!--
position_left = 800;
function moveItemLeft(){
if (position_left >= 10;){
document.all.head.style.left = position_left;
position_left -= 10;
setTimeout("moveItemLeft()",1);
}
}
//-->
</script>
<!-- rest of page here -->
<div id="head" style="position: absolute; top: auto; left: 800;">
Heading Goes Here
</div>
Τώρα αρχίζει η κίνηση καλώντας απλά τη συνάρτηση moveItemLeft();

Ένα μενού το οποίο αυτόματα ολισθαίνει από το αριστερό άκρο της οθόνης καθώς ο χρήστης κινεί το ποντίκι πάνω απ'αυτό.
Βήμα 1: Τοποθετήστε τον παρακάτω κώδικα στο<head> της σελίδας σας.
<style>
<!--
#slidemenubar, #slidemenubar2{
position:absolute;
left:-155px;
width:160px;
top:170px;
border:1.5px solid green;
background-color:lightyellow;
layer-background-color:lightyellow;
font:bold 12px Verdana;
line-height:20px;
}
-->
</style>
Βήμα 2: Tοποθετήστε τον παρακάτω κώδικα στο<body>της σελίδας σας.
<script language="JavaScript1.2">
if (document.all)
document.write('<div id="slidemenubar2" style="left:-150" onMouseover="pull()" onMouseout="draw()">')
</script>
<layer id="slidemenubar" onMouseover="pull()" onMouseout="draw()">
<script language="JavaScript1.2">
var sitems=new Array()
var sitemlinks=new Array()
//extend or shorten this list
sitems[0]="Home"
sitems[1]="Take our survey!"
sitems[2]="Menus And Navigation"
sitems[3]="Document Effects"
sitems[4]="Scrollers"
sitems[5]="Image Effects"
sitems[6]="Links And Buttons"
sitems[7]="Dynamic Clocks & Dates"
sitems[8]="Text Animations"
sitems[9]="Browser Window"
sitems[10]="User System Information"
sitems[11]="Cascading Style Sheets"
sitems[12]="Other"
//These are the links pertaining to the above text.
sitemlinks[0]="../test.htm"
sitemlinks[1]=".."
sitemlinks[2]="../dynamicindex1/index.html"
sitemlinks[3]="../dynamicindex3/index.html"
sitemlinks[4]="../dynamicindex2/index.html"
sitemlinks[5]="../dynamicindex4/index.html"
sitemlinks[6]="../dynamicindex5/index.html"
sitemlinks[7]="../dynamicindex6/index.html"
sitemlinks[8]="../dynamicindex10/index.html"
sitemlinks[9]="../dynamicindex8/index.html"
sitemlinks[10]="../dynamicindex9/index.html"
sitemlinks[11]="../dynamicindex7/index.html"
sitemlinks[12]="../dynamicindex11/index.html"
for (i=0;i<=sitems.length-1;i++)
document.write('<a href='+sitemlinks[i]+'>'+sitems[i]+'</a><br>')
</script>
</layer>
<script language="JavaScript1.2">
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",400)
}
window.onload=regenerate2
if (document.all){
document.write('</div>')
themenu=document.all.slidemenubar2.style
rightboundary=0
leftboundary=-150
}
else{
themenu=document.layers.slidemenubar
rightboundary=150
leftboundary=10
}
function pull(){
if (window.drawit)
clearInterval(drawit)
pullit=setInterval("pullengine()",50)
}
function draw(){
clearInterval(pullit)
drawit=setInterval("drawengine()",50)
}
function pullengine(){
if (document.all&&themenu.pixelLeft<rightboundary)
themenu.pixelLeft+=5
else if(document.layers&&themenu.left<rightboundary)
themenu.left+=5
else if (window.pullit)
clearInterval(pullit)
}
function drawengine(){
if (document.all&&themenu.pixelLeft>leftboundary)
themenu.pixelLeft-=5
else if(document.layers&&themenu.left>leftboundary)
themenu.left-=5
else if (window.drawit)
clearInterval(drawit)
}
</script>

Αλλαγή του φόντου της ιστοσελίδας
Τοποθετήστε τον ακόλουθο κώδικα στο<body>της σελίδας.
<style>
.bgimages img {cursor:hand}
</style>
<script language="JavaScript1.2">
<!--
function tile(){
if (!document.all)
return
var source=event.srcElement
if (source.tagName=="IMG")
document.body.style.backgroundImage="url("+source.src+")"
}
function restore(){
document.body.style.backgroundImage=''
}
document.body.onclick=restore
//-->
</script>
Τέλος, τοποθετήστε τον ακόλουθο κώδικα στην ετικέτα <span >.
<span class="bgimages" onClick="tile();event.cancelBubble=true"><img src="backgr10.jpg"><img src="backgr11.jpg"><br><img src="backgr13.jpg"><img src="backgr14.jpg"></span>

Εμφάνιση εικόνας
<html>
<head>
<!----------------- PLEASE ATTACH THIS IF USED -------------->
<meta name=author
content="MACEDONIA UNIVERSITY">
<meta name=copyright
content="PDPLAB DECEMBER 1, 1999">
<!----------------------------------------------------------->
<style>
body { background:silver; font-family:Arrus BT,Garamond,Times New Roman; }
div { position:absolute; }
</style>
<title>Emboss & 3D Letters</title>
<head>
<body>
Written by<br>
<style>
a { text-decoration: none; color:maroon; vlink:maroon; alink:red;}
a:hover {color: red }
.info { font-family:Times New Roman; positon:relative;}
.light { top:-1; left:-1; color:white;}
.shade { top:+1; left:+1; color:pink; }
.fill { top:0; left:0; color:red; } </style>
<div class="info">
<div class="light">
<i> MACEDONIA UNIVERSITY</i>
</div>
<div class="shade">
<i> PDPLAB</i>
</div>
<div class="fill">
</div>
</div>
<br><br><br>
<!--- Example #1 --->
<style>
.shade1 { top:+5; left:+5; color:black; }
.fill1 { top:0; left:0; color:red; }
</style>
<div class=Example1>
<div class="shade1">
<center><h1>Shadow</h1></center>
</div>
<div class="fill1">
<center><h1>Shadow</h1></center>
</div>
</div>
<br><br><br>
<!--- Example #2 --->
<style>
.light2 { top:-1; left:-2; color:white; }
.shade2 { top:+1; left:+2; color:black; }
.fill2 { top:0; left:0; color:silver; } </style>
<div class=Example2>
<div class="light2">
<center><h1>Emboss Background Example</h1></center>
</div>
<div class="shade2">
<center><h1>Emboss Background Example</h1></center>
</div>
<div class="fill2">
<center><h1>Emboss Background Example</h1></center>
</div>
</div>
<br><br><br>
<!--- Example #3 --->
<style>
.light3 { top:-2; left:-2; color:white; }
.shade3 { top:+2; left:+2; color:lightblue; }
.fill3 { top:0; left:0; color:blue; } </style>
<div class=Example3>
<div class="light3">
<center><h1>Emboss Color Example</h1></center>
</div>
<div class="shade3">
<center><h1>Emboss Color Example</h1></center>
</div>
<div class="fill3">
<center><h1>Emboss Color Example</h1></center>
</div>
</div>
<br><br><br>
<!--- Example #4 --->
<style>
.light4 { top:-2; left:-2; color:yellow; }
.shade4 { top:+2; left:+2; color:yellow; }
.fill4 { top:0; left:0; color:darkgreen; } </style>
<div class=Example4>
<div class="light4">
<center><h1>Color Highlight Example</h1></center>
</div>
<div class="shade4">
<center><h1>Color Highlight Example</h1></center>
</div>
<div class="fill4">
<center><h1>Color Highlight Example</h1></center>
</div>
</div>
</body>
</html>

Ένα σενάριο που προκαλεί σ'ένα κείμενο, που βρίσκεται μέσα σε μια ετικέτα <span>, την εμφάνισή του πληκτρολογώντας ένα γράμμα κάθε φορά.
Τοποθετήστε τον παρακάτω κώδικα οπουδήποτε μέσα στο <body> της σελίδας σας.
<script language="JavaScript1.2">
var it=0
function initialize(){
mytext=typing.innerText
var myheight=typing.offsetHeight
typing.innerText=''
document.all.typing.style.height=myheight
document.all.typing.style.visibility="visible"
typeit()
}
function typeit(){
typing.insertAdjacentText("beforeEnd",mytext.charAt(it))
if (it<mytext.length-1){
it++
setTimeout("typeit()",100)
}
else
return
}
if (document.all)
document.body.onload=initialize
</script>
<small><span id="typing" style="visibility:hidden" align="left">Welcome to Dynamic Drive, the primer place on the net to get FREE Dynamic HTML scripts to enhance your web site! All scripts on this site take advantage of fourth generation browsers (IE 4.x and/or NS 4.x), with emphasis on practicality and backwards compatibility, to bring true power and interactivity to your site. The majority of scripts here are written by the programmers right here at Dynamic Drive, and cannot be found anywhere else on the net. Enjoy!</span></small>
Για να αλλάξετε το μήνυμα απλά αλλάξτε το κείμενο μέσα στην ετικέτα <span>.

Αντίστροφη μέτρηση μιας δοσμένης ημερομηνίας
<script language="JavaScript1.2">
function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}
//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////
//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(2000,1,1)
//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion="the millennium"
var message_on_occasion="Welcome to the millennium!!"
//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='518px'
var countdownheight='20px'
var countdownbgcolor='lightblue'
var opentags='<font face="Verdana"><small>'
var closetags='</small></font>'
//////////DO NOT EDIT PASS THIS LINE//////////////////
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
countdown(2000,1,1)
}
if (document.all)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')
window.onload=start_countdown
function countdown(){
var today=new Date()
var todayy=today.getYear()
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all)
countdownie.innerHTML=opentags+message_on_occasion+closetags
return
}
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all)
countdownie.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</script>
<ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>

Ένα σενάριο που ολισθαίνει δυναμικά στην επιφάνεια του παραθύρου από το αριστερό προς το δεξιό άκρο.
<script language="JavaScript1.2">
//change speed to another integer to alter the scrolling speed. Greater is faster
var speed=2
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}
function scrollwindow(){
if (document.all)
temp=document.body.scrollLeft
else
temp=window.pageXOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=document.body.scrollLeft+speed
else
currentpos=window.pageXOffset+speed
window.scroll(currentpos,0)
}
else{
currentpos=0
window.scroll(currentpos,0)
}
}
function startit(){
setInterval("scrollwindow()",10)
}
window.onload=initialize
</script>

Αριθμομηχανή με έλεγχο λαθών
Τοποθετήστε τον ακόλουθο κώδικα στο <body> της ιστοσελίδας σας.
<table border="2" width="200" cellspacing="0" cellpadding="0" bgcolor="#000000"
style="border-color:black" onClick="previouskey=event.srcElement.innerText">
<tr>
<td width="100%" bgcolor="#FFFFFF" id="result"
style="font:bold 20px Verdana;color:black;text-align='right'">0</td>
</tr>
<tr>
<td width="100%" valign="middle" align="center"><table border="0" width="100%"
cellspacing="0" cellpadding="0" style="font:bold 20px Verdana;color:white">
<tr>
<td width="80%" align="center"><table border="1" width="100%" cellspacing="0"
cellpadding="0" style="cursor:hand;font:bold 20px Verdana;color:white"
onMouseover="if (event.srcElement.tagName=='TD')event.srcElement.style.color='yellow'"
onMouseout="event.srcElement.style.color='white'" onselectStart="return false"
onClick="calculate()" height="82">
<tr>
<td width="25%" align="center" height="17">7</td>
<td width="25%" align="center" height="17">8</td>
<td width="25%" align="center" height="17">9</td>
<td width="25%" align="center" height="17">/</td>
</tr>
<tr>
<td width="25%" align="center" height="19">4</td>
<td width="25%" align="center" height="19">5</td>
<td width="25%" align="center" height="19">6</td>
<td width="25%" align="center" height="19">*</td>
</tr>
<tr>
<td width="25%" align="center" height="19">1</td>
<td width="25%" align="center" height="19">2</td>
<td width="25%" align="center" height="19">3</td>
<td width="25%" align="center" height="19">-</td>
</tr>
<tr>
<td width="25%" align="center" height="19">0</td>
<td width="25%" align="center" height="19"
onClick="pn();previouskey=1;event.cancelBubble=true">+/-</td>
<td width="25%" align="center" height="19">.</td>
<td width="25%" align="center" height="19">+</td>
</tr>
</table>
</td>
<td width="20%"><div align="left"><table border="1" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td width="100%" style="cursor:hand;font:bold 20px Verdana;color:white;text-align:center"
onClick="result.innerText=0;results=''">C</td>
</tr>
</table>
</div><div align="left"><table border="1" width="100%" cellspacing="0" cellpadding="0"
height="81">
<tr>
<td width="100%" style="cursor:hand;font:bold 32px Verdana;color:white;text-align:center"
onMouseover="event.srcElement.style.color='yellow'"
onMouseout="event.srcElement.style.color='white'" onClick="calculateresult()">=</td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="JavaScript1.2">
var results=''
var previouskey=''
var re=/(\/|\*|\+|-)/
var re2=/(\/|\*|\+|-){2}$/
var re3=/.+(\/|\*|\+|-).+/
var re4=/\d|\./
var re5=/^[^\/\*\+].+\d$/
var re6=/\./
function calculate(){
if (event.srcElement.tagName=="TD"){
if (event.srcElement.innerText.match(re4)&&previouskey=="=")
results=''
if (result.innerText.match(re3)&&event.srcElement.innerText.match(re)){
if (!results.match(re5)){
result.innerText="Error!"
return
}
results=eval(results)
if (results.toString().length>=12&&results.toString().match(re6))
results=results.toString().substring(0,12)
result.innerText=results
}
results+=event.srcElement.innerText
if (results.match(re2))
results=results.substring(0,results.length-2)+results.charAt(results.length-1)
result.innerText=results
}
}
function calculateresult(){
if (!results.match(re5)){
result.innerText="Error!"
return
}
results=eval(results)
if (results.toString().length>=12&&results.toString().match(re6))
results=results.toString().substring(0,12)
result.innerText=results
}
function pn(){
if (result.innerText.charAt(0)!='-')
result.innerText=results='-'+result.innerText
else if (result.innerText.charAt(0)=='-')
result.innerText=results=result.innerText*(-1)
}
</script>
</script>
<table border="2" width="200" cellspacing="0" cellpadding="0" bgcolor="#000000"
style="border-color:black" onClick="previouskey=event.srcElement.innerText">
<tr>
<td width="100%" bgcolor="#FFFFFF" id="result"
style="font:bold 20px Verdana;color:black;text-align='right'">0</td>
</tr>
<tr>
<td width="100%" valign="middle" align="center"><table border="0" width="100%"
cellspacing="0" cellpadding="0" style="font:bold 20px Verdana;color:white">
<tr>
<td width="80%" align="center"><table border="1" width="100%" cellspacing="0"
cellpadding="0" style="cursor:hand;font:bold 20px Verdana;color:white"
onMouseover="if (event.srcElement.tagName=='TD')event.srcElement.style.color='yellow'"
onMouseout="event.srcElement.style.color='white'" onselectStart="return false"
onClick="calculate()" height="82">
<tr>
<td width="25%" align="center" height="17">7</td>
<td width="25%" align="center" height="17">8</td>
<td width="25%" align="center" height="17">9</td>
<td width="25%" align="center" height="17">/</td>
</tr>
<tr>
<td width="25%" align="center" height="19">4</td>
<td width="25%" align="center" height="19">5</td>
<td width="25%" align="center" height="19">6</td>
<td width="25%" align="center" height="19">*</td>
</tr>
<tr>
<td width="25%" align="center" height="19">1</td>
<td width="25%" align="center" height="19">2</td>
<td width="25%" align="center" height="19">3</td>
<td width="25%" align="center" height="19">-</td>
</tr>
<tr>
<td width="25%" align="center" height="19">0</td>
<td width="25%" align="center" height="19"
onClick="pn();previouskey=1;event.cancelBubble=true">+/-</td>
<td width="25%" align="center" height="19">.</td>
<td width="25%" align="center" height="19">+</td>
</tr>
</table>
</td>
<td width="20%"><div align="left"><table border="1" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td width="100%" style="cursor:hand;font:bold 20px Verdana;color:white;text-align:center"
onClick="result.innerText=0;results=''">C</td>
</tr>
</table>
</div><div align="left"><table border="1" width="100%" cellspacing="0" cellpadding="0"
height="81">
<tr>
<td width="100%" style="cursor:hand;font:bold 32px Verdana;color:white;text-align:center"
onMouseover="event.srcElement.style.color='yellow'"
onMouseout="event.srcElement.style.color='white'" onClick="calculateresult()">=</td>
</tr>
</table>
</div></td>
</tr>
</table>
</td>
</tr>
</table>
<script language="JavaScript1.2">
var results=''
var previouskey=''
var re=/(\/|\*|\+|-)/
var re2=/(\/|\*|\+|-){2}$/
var re3=/.+(\/|\*|\+|-).+/
var re4=/\d|\./
var re5=/^[^\/\*\+].+\d$/
var re6=/\./
function calculate(){
if (event.srcElement.tagName=="TD"){
if (event.srcElement.innerText.match(re4)&&previouskey=="=")
results=''
if (result.innerText.match(re3)&&event.srcElement.innerText.match(re)){
if (!results.match(re5)){
result.innerText="Error!"
return
}
results=eval(results)
if (results.toString().length>=12&&results.toString().match(re6))
results=results.toString().substring(0,12)
result.innerText=results
}
results+=event.srcElement.innerText
if (results.match(re2))
results=results.substring(0,results.length-2)+results.charAt(results.length-1)
result.innerText=results
}
}
function calculateresult(){
if (!results.match(re5)){
result.innerText="Error!"
return
}
results=eval(results)
if (results.toString().length>=12&&results.toString().match(re6))
results=results.toString().substring(0,12)
result.innerText=results
}
function pn(){
if (result.innerText.charAt(0)!='-')
result.innerText=results='-'+result.innerText
else if (result.innerText.charAt(0)=='-')
result.innerText=results=result.innerText*(-1)
}
</script>

Αλλαγή του χρώματος των κελιών ενός δοσμένου πίνακα καθώς το ποντίκι κυλά πάνω απ'αυτά
<table border="0" width="280" id="myexample" style="border:5px solid green">
<tr>
<td>Insert anything you want into this table.<br>Insert anything you want into this table.<br>Insert anything you want into this table.<br></td>
</tr>
</table>
<script language="JavaScript1.2">
<!--
function flashit(){
if (!document.all)
return
if (myexample.style.borderColor=="green")
myexample.style.borderColor="red"
else
myexample.style.borderColor="green"
}
setInterval("flashit()", 500)
//-->
</script>
 

Αρχική Σελίδα Περιεχόμενα DHTML Παράρτημα Α