Some useful Javascripts
<SCRIPT language="JavaScript">
function getLogin() {
var login=""
while(login=="") {
login = prompt("Enter your name","")
if (login==null) {
if (confirm("Shy ?")) { alert("Anyway !"); this.close(); return }
login=""
}
}
document.write("Hello "+login+" !")
}
</SCRIPT>
Test this script
<SCRIPT language="JavaScript">
function centerPop(url,width,height) { // center PopUp on the screen
var left = (screen.width - width)/2
var up = (screen.height - height)/2
return window.open(url,"","width="+width+",height="+height+",left="+left+",top="+up)
}
function infos() {
var adr = centerPop("",350,230)
adr.document.write("<title>Infos</title><center><b>Your parameters by JavaScript</b></center><br>")
adr.document.write("Resolution : "+screen.width+"x"+screen.height+"<br>")
adr.document.write("Colors : "+screen.colorDepth+" bits<br>")
adr.document.write("Explorer : "+navigator.appName+"<br>")
adr.document.write("Version : "+navigator.appVersion+"<br>")
adr.document.write("Referent : "+document.referrer+"<br>")
adr.document.write("<center><br><A href='javascript:window.close()'>Close this PopUp</A>")
}
</SCRIPT>
Test this script
<SCRIPT language="JavaScript">
function verif(email) {
var arobase = email.indexOf("@"); var point = email.lastIndexOf(".")
if ((arobase < 3)||(point + 2 > email.length)||(point < arobase+3)) return false
return true // if at least 3 letters for the name, 1 letter for the domain and 1 letter for the extension
}
function test(name,mail) {
if (name.value=="") {
alert("Name requested !"); name.focus(); return false
}
if (!verif(mail.value)) {
alert("Invalid email !"); mail.value=""; mail.focus(); return false
}
return true // the formulary can be sent
}
</SCRIPT>
<FORM method="POST" action="my_page.ext" onSubmit="return test(this.thename,this.themail)">
<TABLE><TR>
<TD>Name</TD><TD><input name="thename"></TD>
<TD>Email</TD><TD><input name="themail"></TD>
<TD><input type="Submit" value="Send"></TD>
</TR></TABLE>
</FORM>
<SCRIPT language="VBScript">
sub deroule(zone)
dim Bpt
set Bpt = zone.createTextRange()
Bpt.movestart "textedit",1
Bpt.select()
Bpt.scrollintoview()
end sub
</SCRIPT>
<SCRIPT language="JavaScript">
function doclick(box) {
var d = new Date(), temp=""
with(document.democlick) { // to avoid retyping it...
if (!box.checked) temp="un"
listclick.value += "\n"+temp+"checked at "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()
deroule(listclick)
}
}
</SCRIPT>
<FORM name="democlick">
<input type="checkbox" onclick=doclick(this)>Check me !</input>
<textarea name="listclick" rows=2 cols=30></textarea>
</FORM>
<FORM name="chrono"><input name="timer0" size=40></FORM>
<SCRIPT language="JavaScript">
chro0 = new Date()
function chro() {
var chro1= new Date(); var t = Math.floor((chro1.getTime()-chro0.getTime())/1000)
document.chrono.timer0.value="Page open for "+t+" seconds"
setTimeout("chro()", 1000);
}
chro()
</SCRIPT>
<SCRIPT language="JavaScript">
svbg="" // to save clicked cell
function chng(obj,i) {
if (i==0) // we pass over
obj.setAttribute("BGCOLOR", "red", false) // red
if (i==1) // we pass out
if (obj==svbg) obj.setAttribute("BGCOLOR", "lime", false) // clicked thus green
else obj.setAttribute("BGCOLOR", "white", false) // otherwise white
if (i==2) { // on clique
if (svbg!="") // a cell has already been clicked ?
svbg.setAttribute("BGCOLOR", "white", false) // thus we set it white
svbg=obj // save the new clicked cell
obj.setAttribute("BGCOLOR", "lime", false) // and set it green
}
}
</SCRIPT>
<TABLE bgcolor=white border cellspacing=0 width=170 height=30><TR>
<TH onmouseover=chng(this,0) onmouseout=chng(this,1) onclick=chng(this,2)> </TH>
<TH onmouseover=chng(this,0) onmouseout=chng(this,1) onclick=chng(this,2)> </TH>
<TH onmouseover=chng(this,0) onmouseout=chng(this,1) onclick=chng(this,2)> </TH>
<TH onmouseover=chng(this,0) onmouseout=chng(this,1) onclick=chng(this,2)> </TH>
<TH onmouseover=chng(this,0) onmouseout=chng(this,1) onclick=chng(this,2)> </TH>
</TR></TABLE>
48741 visitors
850589 robots
since 01/01/2003
Page generated
in 1.38 seconds
💗 2003-2024 by S. MARLIERE. Copying is an act of love. Love is not subject to law. Please copy and share.