語法教學

文字變色

<img src= width=0 height=0 onerror="setInterval('font.style.color=Math.random()*255*255*255',500)"><font id="font">輸入你要顯示的字</font>


 

網頁地震

<script>
function shake(n) {
if (self.moveBy){
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
self.moveBy(0,i);
self.moveBy(i,0);
self.moveBy(0,-i);
self.moveBy(-i,0);
}


}
shake(5);
</script>


鎖滑鼠右鍵

<script language="JavaScript"><!--
if (navigator.appName.indexOf("Internet Explorer") != -1)
document.onmousedown = noSourceExplorer;
function noSourceExplorer(){if (event.button == 2 | event.button == 3)
{
alert("
COPY\n");}}
// -->
</script>


<!--在<BODY>與</BODY>之間加入下列語法-->

<table width="450" border="0">
<tr><td id='anima' style="font-size:9pt;color:FFFFFF;font-family:Tahoma">
</td></tr></table>
<SCRIPT Language="JavaScript">
text ="君不見黃河之水天上來,奔流到海不復回;君不見高堂明鏡悲白髮,朝如青絲暮成雪;人生得意須盡歡,莫使金鐏空對月,天生我材必有用,千金散盡還復來。"
word = text.split('.')
i = -1;
j = 0;
start = 0;
scount = 0;
function checkIt() {
with(document.all.anima) {
if(innerText.charAt(innerText.length-1) == "_") {
innerText = innerText.substring(0, innerText.length - 1);
return true;
}
else {
innerText = innerText + "_";
return false;
}
}
}
function blinkfor(count, timing) {
with(document.all.anima) {
if(start < count) {
if(checkIt()) {
start++;
}
mistake = 'blinkfor('+count+','+timing+')';
setTimeout('eval(mistake)', timing);
}
else {
start = 0;
i++;
call_It();
}
}
}
function mispell(offset,correction) {
with(document.all.anima) {
if(scount < offset) {
if(!checkIt()) {
innerText = innerText.substring(0, innerText.length-2) + "_";
scount++;
}
mistake = 'mispell(' + offset + ', "' + correction + '")';
setTimeout("eval(mistake)", 150);
}
else {
if(correction == '' && scount == offset ) {
i = i - offset;
scount++;
}
if(offset > 0) {
if(checkIt()) {
innerText += correction.charAt(correction.length - offset) + "_";
offset--;
}
mistake = 'mispell(' + offset + ',"' + correction + '")';
setTimeout("eval(mistake)", 150);
}
else {
scount = 0;
j++;
innerText = innerText.substring(0, innerText.length - 1);
call_It();
}
}
}
}
function spellit(string) {
with(document.all.anima) {
if(i <= string.length) {
if(string.charAt(i) == '/') {
NumErrs = string.charAt(i + 1);
NewLets = string.substring(i + 2, i + NumErrs);
mispell(NumErrs,NewLets);
}
else if(i <= string.length - 1) {
i++;
innerText = string.substring(0,i) + "_";
mistake = 'spellit("' + string + '")';
setTimeout("eval(mistake)", 150);
}
else {
innerText = string.substring(0, i);
j++;
call_It();
}
}
}
}
function call_It() {
with(document.all) {
if(i == -1){
blinkfor(4, 150);
}
else if(j <= word.length - 1) {
spellit(anima.innerText + " " + word[j]);
}
else {
blinkfor(100,230);
}
}
}
if(document.all) {
call_It();
}
</SCRIPT>


如有更多語法可分享,請電郵給我