Các đoạn code Javascript hay cho website

pdf 76 trang hapham 1710
Bạn đang xem 20 trang mẫu của tài liệu "Các đoạn code Javascript hay cho website", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên

Tài liệu đính kèm:

  • pdfcac_doan_code_javascript_hay_cho_website.pdf

Nội dung text: Các đoạn code Javascript hay cho website

  1. Các đoạn code javascript hay cho website
  2. các đoạn code javascript hay cho website 1)Không Cho Click Chuột Phải function right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert('Chuc Mot Ngay Vui ve - Gui Wedsite Cho Ban Be Cua Minh Nha !'); return false; } return true; } document.onmousedown=right; if (document.layers) window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right;
  3. 2)CODE Làm Thanh Tiêu Đề Web Chạy Trên Task Manager Khi Đóng Mở Web title_tmp1=document.title if (title_tmp1.indexOf(">>")!=-1){ title_tmp2=title_tmp1.split(">>"); title_last="*~*"+title_tmp2[1]; title_last=title_last + "*~*" + title_tmp2[2]; }else{ if (title_tmp1.indexOf("*~*")!=-1){ title_tmp2=title_tmp1.split("*~*"); title_last="*~*"+title_tmp2[1]; if (title_last=="*~*"){title_last="*~*"}; if (title_last=="*~*"){title_last="*~*"}; } else { title_last=" wWw.KyNiemB2.Top1.Vn "}
  4. } title_new=""+title_last+"" step=0 function flash_title() { step++ if (step==8) {step=1} if (step==1) {document.title='[ *'+title_new+'* ]'} if (step==2) {document.title='[ *-'+title_new+'-* ]'} if (step==3) {document.title='[ * '+title_new+' * ]'} if (step==4) {document.title='[-* '+title_new+' *-]'} if (step==5) {document.title='[ * '+title_new+' * ]'} if (step==6) {document.title='[ *-'+title_new+'-* ]'} if (step==7) {document.title='[ *'+title_new+'* ]'} setTimeout("flash_title()",180); } flash_title()
  5. 3)CODE Chống Click Chuột Phải Và Làm "Giật Giật Web Nêu Người Xem Cứ Cố ý Click Right document.onmousedown=click var times=0 var times2=10 function click() { if ((event.button==2) || (event.button==3)) { if (times>=1) { earthquake() } alert("Ban Ko Dc Click Chuot Phai"); times++ } } function earthquake() { alert("Ban Ko Dc Click Chuot Phai"); window.moveTo(0, 0) window.moveTo(1, 1) window.moveTo(2, 2)
  6. window.moveTo(3, 3) window.moveTo(4, 4) window.moveTo(5, 5) window.moveTo(6, 6) window.moveTo(7, 7) window.moveTo(8, 8) window.moveTo(9, 9) window.moveTo(10, 10) window.moveTo(9, 9) window.moveTo(8, 8) window.moveTo(7, 7) window.moveTo(6, 6) window.moveTo(5, 5) window.moveTo(4, 4) window.moveTo(3, 3) window.moveTo(2, 2) window.moveTo(1, 1)
  7. alert("Giat Nhu Fiml Nha??!") tremmors() } function tremmors() { window.moveTo(0, 0) window.moveTo(1, 1) window.moveTo(2, 2) window.moveTo(3, 3) window.moveTo(4, 4) window.moveTo(5, 5) window.moveTo(6, 6) window.moveTo(7, 7) window.moveTo(8, 8) window.moveTo(9, 9) window.moveTo(10, 10) window.moveTo(11, 11) window.moveTo(12, 12)
  8. window.moveTo(9, 9) window.moveTo(8, 8) window.moveTo(7, 7) window.moveTo(6, 6) window.moveTo(5, 5) window.moveTo(4, 4) window.moveTo(3, 3) window.moveTo(2, 2) window.moveTo(1, 1) tremmors() } 4)CODE Làm Con Chuột Có Mấy Cái Vòng Chạy Chạy Xung Quanh <! Mouse Attack by Kurt Grigg - var num=10;//Number of dots!
  9. var vel=20;//Speed! var col=new Array('#0080ff','#ffffff','#0000ff','#44ccff');//Dot colours, min 2! var stopafter=60; //Stop and clear after x secondS! //Nothing needs altering past here var MAy=0; var MAx=0; var py=0; var px=0; var angle=0; var distance=0; var rep; var ry=0; var rx=0; var tmr=null; var n4=(document.layers); var n6=(document.getElementById&&!document.all); var ie=(document.all);
  10. var o6=(navigator.appName.indexOf("Opera") != -1)?true:false; var _d=(n4||ie)?'document.':'document.getElementById(" '; var _a=(n4||n6)?'':'all.'; var _r=(n6)?'")':''; var _s=(n4)?'':'.style'; var v=(n4)?"show":"visible"; var put=false; stopafter*=1000; if (n4||n6){ window.captureEvents(Event.MOUSEMOVE); function mouse1(e){ if (put) return false; MAy = e.pageY-window.pageYOffset; MAx = e.pageX; } if (n4) window.onMouseMove=mouse1; else document.onmousemove=mouse1;
  11. } if (ie||o6){ function mouse2(){ if (put) return false; MAy = (ie)?event.clientY:event.clientY-window.pageYOffset; MAx = event.clientX; } document.onmousemove=mouse2; } if (n4){ for (inc=0; inc '); } else{ if (ie&&!o6){ document.write(" ");
  12. document.write(" "); } for (inc=0; inc . '); if (ie&&!o6) document.write(" "); } function pos(){ h=(ie)?document.body.clientHeight:window.innerHeig ht-20; w=(ie)?document.body.clientWidth:window.innerWidth-20; ry=Math.round(Math.random()*h); rx=Math.round(Math.random()*w); rep=Math.round(Math.random()*3); if (rep == 3)ry=0; if (rep == 2)ry=h; if (rep == 1)rx=0; if (rep == 0)rx=w;
  13. py=ry; px=rx; } pos(); function followleader(){ sy=(!ie)?window.pageYOffset:0; sx=(!ie)?window.pageXOffset:0; if (ie) outer.style.top=document.body.scrollTop; for (inc=0; inc < num; inc++){ randomcol=col[Math.floor(Math.random()*col.length)]; temp1=eval(_d+_a+"dots"+inc+_r+_s); temp1.visibility=v; if (inc < num-1){ temp2=eval(_d+_a+"dots"+(inc+1)+_r+_s); temp1.top=temp2.top; temp1.left=temp2.left }
  14. else{ temp1.top=py+sy; temp1.left=px; } if (n4)temp1.bgColor=randomcol; else temp1.background=randomcol; } } function bomb(){ ay=MAy-py; ax=MAx-px; angle=Math.round(Math.atan2(ay,ax)*180/Math.PI); if (angle < 0) angle += 360; MAdy=py-MAy; MAdx=px-MAx; distance=Math.floor(Math.sqrt(MAdx*MAdx+MAdy*MAdy) ); go_y = Math.round(vel*Math.sin(angle*Math.PI/180));
  15. go_x = Math.round(vel*Math.cos(angle*Math.PI/180)); py+=go_y; px+=go_x; if (distance
  16. 5)TITLE Chạy var txt=" :: WelCome To Website | wWw.KyNiemB2.Top1.Vn | Mang Giai Tri Online -> 12B2 THPT EaH'Leo - Daklak - Design : HoangVu Entertainment© -"; var expert=200; // speed of roll var refresh=null; function marquee_title(){ document.title=txt; txt=txt.substring(1,txt.lenghth)+txt.charAt(0); refresh=setTimeout("marquee_title()",expert); } marquee_title(); 6)Dòng Chữ Chạy Dưới web
  17. puchtit=")«-»( :: Welcome To WwW.NhoOi.Kiss.To :: )«-»("; letrero2="•.¸¸.•´´¯`••._.•"; letrero1="•.¸¸.•´´¯`••._.•";ultimo1=letr ero1.length-1; ultimo2=letrero2.length-1; tiempo=setTimeout("scroll()",.100); function scroll() { aux1=letrero1.charAt(ultimo1-1); letrero1=aux1+letrero1.substring(0,ultimo1-1); aux2=letrero2.charAt(0); letrero2=letrero2.substring(1,ultimo2+1)+aux2; window.status="(" + letrero1 + ")(" + letrero2 + puchtit + letrero1 + ")(" + letrero2 + ")"; tiempo=setTimeout("scroll()",.100); return true; } // >
  18. 7)Tạo 1 Button Giờ Trên Website <! Begin day = new Date(); miVisit = day.getTime(); function clock() { dayTwo = new Date(); hrNow = dayTwo.getHours(); mnNow = dayTwo.getMinutes(); scNow = dayTwo.getSeconds(); miNow = dayTwo.getTime(); if (hrNow == 0) { hour = 12; ap = " AM"; } else if(hrNow <= 11) { ap = " AM";
  19. hour = hrNow; } else if(hrNow == 12) { ap = " PM"; hour = 12; } else if (hrNow >= 13) { hour = (hrNow - 12); ap = " PM"; } if (hrNow >= 13) { hour = hrNow - 12; } if (mnNow <= 9) { min = "0" + mnNow; } else (min = mnNow) if (scNow <= 9) { secs = "0" + scNow;
  20. } else { secs = scNow; } time = hour + ":" + min + ":" + secs + ap; document.form.button.value = time; self.status = time; setTimeout('clock()', 1000); } function timeInfo() { milliSince = miNow; milliNow = miNow - miVisit; secsVisit = Math.round(milliNow / 1000); minsVisit = Math.round((milliNow / 1000) / 60); alert("There have been " + milliSince + " milliseconds since midnight, January 1, 1970. " + "You have spent " + milliNow + " of those milliseconds on this page. " + " About " + minsVisit + " minutes, and "
  21. + secsVisit + " seconds."); } document.write(" " + " "); onError = null; clock(); // End > 8)Bộ Đếm 10 , 9 0 BODY A:link { COLOR: #253d59; TEXT-DECORATION: none } A:visited {
  22. COLOR: #253d59; TEXT-DECORATION: none } A:hover { padding:0px; BACKGROUND: #ffffff; MARGIN: 0px; COLOR: #253d59; tahoma: } A:active { padding:0px; BACKGROUND: #ffffff; MARGIN: 0px; COLOR: #253d59; tahoma: } HTML { SCROLLBAR-FACE-COLOR: #ffffff; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT- COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #8b8b8b; SCROLLBAR- TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #7a7a7a } BODY { SCROLLBAR-FACE-COLOR: #ffffff; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #ffffff; SCROLLBAR-3DLIGHT-
  23. COLOR: #ffffff; SCROLLBAR-ARROW-COLOR: #8b8b8b; SCROLLBAR- TRACK-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #7a7a7a } [ W w. K y Ni e m B2 .T o p<FONT
  24. color=#ff3399>1 .V n ] Thay Đôi? Tên Miê`n Chính Thú*c var c=10; var t; var theDate = new Date(); s=theDate.getSeconds(); function ChangeUrl(site){ document.getElementById("txt").innerHTML=' <FONT
  25. face="Tahoma">Trình duyệt sẽ tự động chuyển sang '+site+' trong vòng '+c+' giây nữa. '; document.getElementById("txt").innerHTML+=' '; c-=1; url=site; t=setTimeout("ChangeUrl(url)",1000); stopCount(c,url); } function stopCount(c,link){ if(c==-1) {clearTimeout(t); location.href=link;} }
  26. ChangeUrl(' Design : Hô` Ho àng Vũ ® Website :wWw.KyNiemB2.Top1.Vn 9)Chữ ẩn hiện và thay đổi chữ
  27. Chao mung cac ban den voi ThangBomBH Homepages ! "; msg[1]=" Chuc cac ban luon thanh dat va vui ve. "; msg[2]=" Just type in \" \" "; msg[3]=" Cam on cac ban da ghe tham ! "; // set your first set of colors. Use as many or as few as you wish. var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff", "8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222ff", "1111ff", "0000ff") //set your second set of colors
  28. // must have exactly the same number of colors as the array above var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc", "ffbbbb", "ffaaaa", "ff9999", "ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333", "ff2222", "ff1111", "ff0000") //set the height of the display in pixels high=60; //set the width of the display in pixels wide=350; //set the pixel coordinates for the upper left hand corner of the display Xpos=220; Ypos=180; // move the display away from the edges of the background pad=15; // set the background color of the display bgcol="ffffff"; //add a background image if you want. // for no image, just leave empty quotes (ex. cellbg=""; )
  29. cellbg="faderbg.jpg"; // set the font fntFam="verdana,helvetica,arial"; fntSize=14; // set how how many seconds you want the message to stay remain at totality. pause=2.5; // Do not edit these values below!!! icolor=0; mcolor=1; imsg=0; spWidth=wide-(2*pad); totality=false; glowing=true; var theMsg=""; var cellcontent=""; pause=pause*1000; if(cellbg.length>4){cellbg=" background="+cellbg}
  30. else{cellbg="";} function doPause(){ totality=false; t=setTimeout("changecolor()",pause); } function initiate(){ getContentColor(); getMsg(); getCellContent(); if(document.all){ msgbg.innerHTML=cellcontent; msgfade.innerHTML=theMsg; msgbg.style.posLeft=Xpos; msgbg.style.posTop=Ypos; msgfade.style.posLeft=Xpos+pad; msgfade.style.posTop=Ypos+pad; t=setTimeout("changecolor()",50);} if(document.layers){
  31. document.msgbg.document.write(cellcontent); document.msgbg.document.close(); document.msgfade.document.write(theMsg); document.msgfade.document.close(); document.msgbg.left=Xpos; document.msgbg.top=Ypos; document.msgfade.left=Xpos+pad; document.msgfade.top=Ypos+pad; t=setTimeout("changecolor()",100);} } function changecolor(){ if(totality==true){doPause();} else{ getMsg(); getContentColor(); if(document.all){ msgfade.innerHTML=theMsg;
  32. t=setTimeout("changecolor()",50);} if(document.layers){ document.msgfade.document.write(theMsg); document.msgfade.document.close(); t=setTimeout("changecolor()",70);} } } function getFadeColor(){ icolor=icolor-1; if(mcolor==1){contentcolor=colors1[icolo r];} else{contentcolor=colors2[icolor];} } function getGlowColor(){ icolor=icolor+1; if(mcolor==1){contentcolor=colors1[icolo r];}
  33. else{contentcolor=colors2[icolor];} } function changemsg(){ if(imsg==msg.length-1){imsg=0; mcolor=1;} else if(imsg != msg.lenght-1 && mcolor==1){imsg=imsg+1; mcolor=0;} else{imsg=imsg+1; mcolor=1;} } function getContentColor(){ if(icolor==colors1.length-1 && glowing==true){ getFadeColor(); glowing=false; totality=true;} else if(icolor < colors1.length && glowing==true){ getGlowColor();} else if(icolor < 1 && glowing==false){changemsg(); getGlowColor(); glowing=true;} else{getFadeColor();} } function getMsg() {
  34. theMsg=" " theMsg+=" "+msg[imsg]+" " theMsg+=" " } function getCellContent(){ cellcontent=" "} // End >
  35. 10)Link đổi màu tự động <! Begin function initArray() { for (var i = 0; i < initArray.arguments.length; i++) { this[i] = initArray.arguments[i]; } this.length = initArray.arguments.length; } var colors = new initArray( "red", "blue", "green", "purple", "black",
  36. "tan", "red"); delay = .5; // seconds link = 0; vlink = 2; function linkDance() { link = (link+1)%colors.length; vlink = (vlink+1)%colors.length; document.linkColor = colors[link]; document.vlinkColor = colors[vlink]; setTimeout("linkDance()",delay*1000); } linkDance(); // End >
  37. 11)Chữ vòng quanh theo con trỏ <! Begin if (document.all) { //Things you can alter yourLogo = "Welcome to ThangBomBH Homepages !"; //Not less than 2 letters! logoFont = "Arial"; logoColor = "000000"; //Nothing needs altering below! yourLogo = yourLogo.split(''); L = yourLogo.length;
  38. TrigSplit = 360 / L; Sz = new Array() logoWidth = 100; logoHeight = -30; ypos = 0; xpos = 0; step = 0.03; currStep = 0; document.write(' '); for (i = 0; i '+yourLogo[i]+' '); } document.write(' ');
  39. function Mouse() { ypos = event.y; xpos = event.x - 5; } document.onmousemove=Mouse; function animateLogo() { outer.style.pixelTop = document.body.scrollTop; for (i = 0; i < L; i++) { ie[i].style.top = ypos + logoHeight * Math.sin(currStep + i * TrigSplit * Math.PI / 180); ie[i].style.left = xpos + logoWidth * Math.cos(currStep + i * TrigSplit * Math.PI / 180); Sz[i] = ie[i].style.pixelTop - ypos; if (Sz[i] < 5) Sz[i] = 5; ie[i].style.fontSize = Sz[i] / 1.7; } currStep -= step; setTimeout('animateLogo()', 20);
  40. } window.onload = animateLogo; } // End > 12)Chữ chạy theo con trỏ, chữ này có bóng <! Begin message = 'Welcome to ThangBomBH Homepages !'; FonT = 'Verdana'; ColoR = '999999'; SizE = 3; //1 to 7 only!
  41. var amount = 5, ypos =- 50, xpos = 0, Ay = 0, Ax = 0, By = 0, Bx = 0, Cy = 0, Cx = 0, Dy = 0, Dx = 0, Ey = 0, Ex = 0; if (document.layers) { for (i = 0; i '+message+' '); } window.captureEvents(Event.MOUSEMOVE); function nsmouse(evnt) { xpos = evnt.pageX + 20; ypos = evnt.pageY + 20; } window.onMouseMove = nsmouse; } else if (document.all) { document.write(" "); document.write(" "); for (i = 0; i < amount; i++) {
  42. document.write(' '+message+' ') } document.write(" "); document.write(" "); function iemouse() { ypos = event.y + 20; xpos = event.x + 20; } window.document.onmousemove = iemouse; } function makefollow() { if (document.layers) { document.layers['nsl'+0].top = ay; document.layers['nsl'+0].left = ax; document.layers['nsl'+1].top = by;
  43. document.layers['nsl'+1].left = bx; document.layers['nsl'+2].top = cy; document.layers['nsl'+2].left = cx; document.layers['nsl'+3].top = Dy; document.layers['nsl'+3].left = Dx; document.layers['nsl'+4].top = Ey; document.layers['nsl'+4].left = Ex; } else if (document.all) { outer.style.pixelTop = document.body.scrollTop; text[0].style.pixelTop = ay; text[0].style.pixelLeft = ax; text[1].style.pixelTop = by; text[1].style.pixelLeft = bx; text[2].style.pixelTop = cy; text[2].style.pixelLeft = cx; text[3].style.pixelTop = Dy;
  44. text[3].style.pixelLeft = Dx; text[4].style.pixelTop = Ey; text[4].style.pixelLeft = Ex; } } function move() { ey = Ey += (ypos - Ey) * 0.2; ex = Ex += (xpos - Ex) * 0.2; dy = Dy += (ey - Dy) * 0.3; dx = Dx += (ex - Dx) * 0.3; cy = Cy += (dy - Cy) * 0.4; cx = Cx += (dx - Cx) * 0.4; by = By += (cy - By) * 0.5; bx = Bx += (cx - Bx) * 0.5; ay = Ay += (by - Ay) * 0.6; ax = Ax += (bx - Ax) * 0.6; makefollow();
  45. setTimeout('move()', 10); } window.onload=move; // End > 13)Chuỗi các ngôi sao bay theo Mouse Chú ý : Cần ảnh 6 ngôi sao , đặt nó trong 1 thư mục có tên là Images, bên ngoài thư mục đó là trang web có chứa đoạn mã bên dưới Hieu u'ng JavaScript - Le Quang Anh Hu'ng
  46. #trailsprite1 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 1px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 100 }
  47. #trailsprite2 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 10 } #trailsprite3 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 10 } #trailsprite4 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 10 } #trailsprite5 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 10 } #trailsprite6 { HEIGHT: 10px; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: visible; WIDTH: 10px; Z-INDEX: 10
  48. } if (version > 3) 3 (JavaScript) khi đó sẽ xuất ra màn hình bức ảnh thứ 1 và thứ tự tiếp theo ứng với mỗi images bao gồm chiều cao, viền, tên, Id > document.write(' ')
  49. // > <! var isNS = (navigator.appName == "Netscape"); layerRef = (isNS) ? "document" : "document.all"; styleRef = (isNS) ? "" : ".style"; var queue = new Array();var NUM_OF_TRAIL_PARTS = 6 for (x=1; x < 7; x++) { ///////////////Image Preload eval("trailSpriteFrame" + x + "=new Image(10,10);");
  50. eval("trailSpriteFrame" + x + ".src='images/trailgif"+x+".gif';"); }////////////////////////////////////////////////Đối tượng vệt ngôi sao chạy theo mouse function trailSpriteObj(anID) { this.trailSpriteID = "trailSprite" + anID; //Tùy đằng trước this.imgRef = "trailSprite" + anID + "img"; //Chuyển tới tên những ngôi sau this.currentFrame = 1; //nhìn thấy khung this.animateTrailSprite = animateTrailSprite; //Khai báo phương pháp vòng lặp đối tượng } function animateTrailSprite() { if (this.currentFrame <7) {// Nếu có hoạt cảnh (mà) những khung rời bỏ, thay đổi những ngôi sao kết cấu hiện thời if (isNS) { //Phát hiện ra bộ duyệt và thực hiện sự chuyển đổi hình ảnh
  51. eval("document['"+this.imgRef+"'].src=trailSpriteFrame" + this.currentFrame + ".src"); } else { eval("document['"+this.imgRef+"'].src=trailSpriteFrame" + this.currentFrame + ".src"); } this.currentFrame ++; //và tăng thêm hiện thời những đối tượng hình ảnh } else { //Khung hiện hành như vậy đạt đến giới hạn nó che dấu ngôi sao eval(layerRef + '.' + this.trailSpriteID + styleRef + '.visibility="hidden"'); } }///////////////////////////////////////////////////////////////// function processAnim() { for(x=0; x < NUM_OF_TRAIL_PARTS; x++)
  52. queue[x].animateTrailSprite(); } function processMouse(e) { currentObj = shuffleQueue(); if (isNS) { eval("document." + currentObj + ".left=e.pageX-0;"); eval("document." + currentObj + ".top=e.pageY+5;"); } else { eval("document.all." + currentObj + ".style.pixelLeft=event.clientX+document.body.scro llLeft-0;"); eval("document.all." + currentObj + ".style.pixelTop=event.clientY+document.body.scrol lTop+5;"); } }
  53. function shuffleQueue() { lastItemPos = queue.length - 1; lastItem = queue[lastItemPos]; for (i = lastItemPos; i>0; i ) queue[i] = queue[i-1]; queue[0] = lastItem; queue[0].currentFrame = 1; //sự sắp đặt lại số thứ tự hình ảnh của những đối tượng & làm cho ngôi sao rõ ràng thêm eval(layerRef + '.' + queue[0].trailSpriteID + styleRef + '.visibility="visible"'); return queue[0].trailSpriteID; } function init() { for(x=0; x<NUM_OF_TRAIL_PARTS; x++) //Sắp hàng đầy đủ vệt dài của đối tượng queue[x] = new trailSpriteObj(x+1); if (isNS)
  54. { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = processMouse; setInterval("processAnim();",25); } if (version > 3) window.onload = init; // > 14)Tạo Một Trận Sao Rơi Bằng JavaScript Các bạn hãy nhúng đoạn Java Script bên dưới vào trang web của bạn đồng thời kết hợp với 1 image. Mức độ tương thích trình duyệt rất tốt, nó có thể tương thích với cả 2 trình duyệt Internet Explorer & Netscape Navigator. Bạn hãy copy đoạn Java Script dán vào Notepad sau đó lưu lại thành file có đuôi .htm hoặc .html.
  55. Các bạn lưu ý: Khi tạo 1 image này các bạn cần tạo image này càng nhẹ nhàng chừng nào thì bông tuyết gơi càng nhẹ nhàng và uyển chuyển chừng đó, image này phải đạt mức độ trong suốt, kích thước bức ảnh càng nhỏ thì càng đỡ phải che mất chữ của bạn Hieu Ung JavaScript Tuyet Dang Roi - Le Hu'ng Homepage <! Begin var no = 25; // Số tuyết var speed = 10; // Số càng nhỏ tuyết di chuyển(rơi) càng nhanh var snowflake = " "; // Nơi đây chèn hình bông tuyết var ns4up = (document.layers) ? 1 : 0; // Bộ duyệt tìm nạp vào var ie4up = (document.all) ? 1 : 0; var dx, xp, yp; // tọa độ và những vị trí thay đổi
  56. var am, stx, sty; // Độ rộng và những bước thay đổi var i, doc_width = 800, doc_height = 600; if (ns4up) { doc_width = self.innerWidth; doc_height = self.innerHeight; } else if (ie4up) { doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx = new Array(); xp = new Array(); yp = new Array(); am = new Array(); stx = new Array(); sty = new Array(); for (i = 0; i < no; ++ i) { dx[i] = 0; // những biến đổi toạ độ tập hợp
  57. xp[i] = Math.random()*(doc_width-50); // tập hợp những thay đổi vị trí yp[i] = Math.random()*doc_height; am[i] = Math.random()*20; // tập hợp những thay đổi độ rộng stx[i] = 0.02 + Math.random()/10; // tập hợp những thay đổi bước sty[i] = 0.7 + Math.random(); //tập hợp những thay đổi bước if (ns4up) { // những lớp tập hợp if (i == 0) { document.write(" "); } else { document.write(" "); } } else if (ie4up) { if (i == 0) {
  58. document.write(" "); } else { document.write(" "); } } } function snowNS() { // hàm Netscape hoạt cảnh chính for (i = 0; i doc_height-50) { xp[i] = Math.random()*(doc_width-am[i]-30);
  59. yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = self.innerWidth; doc_height = self.innerHeight; } dx[i] += stx[i]; document.layers["dot"+i].top = yp[i]; document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]); } setTimeout("snowNS()", speed); } function snowIE() { // hàm IE hoạt cảnh chính for (i = 0; i doc_height-50) { xp[i] = Math.random()*(doc_width-am[i]-30);
  60. yp[i] = 0; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx[i] += stx[i]; document.all["dot"+i].style.pixelTop = yp[i]; document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]); } setTimeout("snowIE()", speed); } if (ns4up) { snowNS(); } else if (ie4up) { snowIE(); }
  61. // End > 15)Banner tự động chạy
  62. <! var xsImgs = new Array("banner.jpg","banner1.jpg","banner2.jpg","ba nner3.jpg","banner4.jpg","banner5.jpg","banner6.jp g","banner7.jpg","banner8.jpg"); var xsImgLinks = new Array(" "," "," ","htt p://maiyeuem.li/");
  63. var xsImgTexts = new Array(" "," "," "); var xsImgSize = new Array(focus_width, focus_height); // > [hr] ghi chú 1 các bạn nên thay đổi các size chiều cao x chiều rộng nếu có thể tùy ý các bạn 16)Đặt bộ đếm trên trang Web Ngay khi đưa trang web đầu tiên của mình lên Internet, bạn đã muốn biết có bao nhiêu người sẽ đến đọc trang web đó.Cũng như bạn,tôi đã từng sử dụng khá nhiều những bộ đếm miễn phí.Nhưng rồi không bằng lòng với những gì được cho không, cộng với chút công sức tìm hiểu, tôi đã tìm ra các làm bộ đếm cho mình.
  64. Vì bộ đếm này được biết bằng PHP nên điều kiện để bộ đếm hoạt động được là website của bạn phải hỗ trợ PHP.Nếu muốn lưu giữ website miễn phí thì đây là một số nhà cung cấp dịch vụ lưu website có hỗ trợ PHP: ourceforge.net, Sau đây là hướng dẫn nhanh để bạn có được bộ đếm trên trang web của mình. Bước 1: Mở tệp web muốn đặt bộ đếm bằng một trình soạn thảo văn bản như Notepad, EditPlus, UltraEdit.Mã HTML trang web của bạn sẽ hiện lên trong trình soạn thảo. Bước 2:TÌm đến bị trí bạn muốn hiện bộ đếm và dán đoạn mã PHP dưới đây vào: Bước 3:Lưu tệp.Nếu tệp có phần mở rộng là .html thì đổi tên sang .php. Ví dụ
  65. index.htm thì đổi thành index.php. Có vậy thì sever mới hiểu và thi hành đoạn mã để hiện bộ đếm. Bước 4: Tạo một tệp văn bản có tên index.log để lưu giá trị đếm.Nội dung tệp này là một con số bất kỳ mà bạn muốn bắt đầu cho bộ đếm của mình (ta hãy bắt đầu bằng con số 0).Nhớ dừng thêm dấu cách, Enter hay một ký tự nào khác ngoài con số trên. Bước 5:Upload tệp web chứa bộ đếm (index.php) và tệp index.log lên website của bạn và nhớ đặt thuộc tính cho tệp index.log là writable bằng lệnh chmod 777. Bầy giờ, hãy đánh địa chỉ tệp web của mình trong trình duyệt, bạn sẽ thấy trang web hiện lên cùng với bộ đếm.Mỗi lần bạn nhấn nút Refresh thì bộ đếm lại tăng lên 1 đơn vị. Nay ta hãy nhìn sâu vào đoạn mã PHP một chút .Nguyên lý chung của các bộ đếm là lưu giá trị đếm vào một tệp riêng, mỗi lần có người truy cập đến tệp web là sẽ đọc giá trị lưu trong tệp đếm, tăng thêm 1, ghi lại vào tệp đếm và hiện giá trị đó lên màn hình. Trước hết ta cần cho chương trình biết giá trị đếm được lưu ở đâu hay nói cách khác, tên tệp lưu giá trị đếm là gì: $CountFile = "index.log"; Dùng các hàm xử lý tệp do PHP cung cấp, ta lần lượt mở tệp ở chế độ đọc("r" có nghĩa là "reading") và gán con trỏ tệp cho biến $CF: $CF = fopen($CountFile,"r");
  66. đọc toàn bộ nọi dung tệp và lưu vào biến $Hits: $Hits = fread ($CF, filesize($CountFile)); và đóng tệp lại sau khi đọc xong: fclose ($CF); Gia trị đếm hiện tại đã lưu ở biến $Hits, giờ ta tăng biến này thêm 1 để chỉ rằng đã có thêm một người nữa truy cập trang web: $Hits++; Các bước tiếp theo cũng tương tự như ở trên.Ta mở tệp ở chế độ ghi ("w" có nghĩa là "writing"),ghi lại biến $Hits(đã tăng thêm 1 so với trước) và đóng tệp sau khi ghi xong: $CF = fopen($CountFile,"w"); fwrite ($CF,$Hits); fclose($CF); Việc cuối cùng là ta hiện giá trị đếm lên màn hình: echo($Hits); Giá trị đếm này hiện lên ở chế độ văn bản, sử dụng đúng loại font mà bạn đang dùng trong trang web.Nếu bạn muôn thay đổi kiểu chữ, cỡ chữ, màu sắc để làm nổi bật bộ đếm, bạn có thể sử dụng thẻ trong mã HTML để làm điểu này Bạn chắc cũng chưa thảo mãn với bộ đếm ở dạng văn bản mà muốn bộ đếm được thể hiện ở dạng đồ họa, giống như ở các trang web chuyên nghiệp khác.Việc này không khó.Bạn cần có thêm các tệp ảnh (dạng .gif hoặc .jpg)
  67. chứa các con số từ 0 đến 9. Bạn có thể tải về nhiều tệp ảnh với các hình dạng con số khác nhau tại Digitmania.Giả sử các tệp ảnh này có tên lần lượt là 0.gif, 1.gif, 9.gif - mỗi tệp tương ứng với một con số, và các tệp ảnh này đều lưu cũng thư mục với tệp index.php trên sever Đoạn mã PHP trong tệp index.php sẽ như sau: "; } ?> Bạn thấy là những dòng đầu hoàn toàn giống như trước. Sự khác nhau chỉ bắt đầu ở dong cuối cùng.Thay vì dòng lệnh echo($Hits); ta dùng vòng lặp for để lần lượt tạc từng con số trong giá trị đếm và lưu tạm vào một biện gọi là
  68. $Digit: $Digit = substr ($Hits,$i,1); Sau đó ta sẽ dùng thẻ của HTML để chỉ ra các tệp ảnh nào ta muốn hiện tương ứng với từng còn số trong giá trị đếm: echo" "; Ví dụ giá trị đếm lưu trong biến $Hits là 865.Giá trị này gồm 3 chữ số nên vòng lặp for sẽ được thực hiện 3 lần. Tại lần thứ nhất, biến $Digit sẽ được gán với con số thứ nhất, tức là 8.Lần thứ hai và thứ ba,biến $Digit sẽ lần lượt nhận giá trị 6 và 5.Kết quá là trang web index.php khi xuất hiện trong trình duyệt của người dùng sẽ có mã HTML thực tế là: và trình duyệt sẽ hiện lên 3 tệp ảnh tương ứng với các con số 8,6,5, tạo thành một dãy số hoàn chỉnh là số lần trang web đã được truy cập 17)Cách Add bộ gõ tiếng việt vào 4rum Vào Admin Control Panel >> Styles & Templates >> Search in Templates >> Chọn Style đang dùng >> Search for Text >> Đánh vào từ khóa: footer >> Double click vào footer >> kéo xuống cuối cùng của Template này và copy đoạn code sau dán vào - Tiếp tục vào VBulletin Options >> Censorship Options >> Edit Options >> Blank Character Stripper >> Xóa hết dãy số và kí tự trong ô này đi. - Thế là xong phần bộ gõ cho Diễn Đàn rồi đó
  69. + Nhúng vào Admin Control Panel: - Tiếp tục upload file him.js vào thư mục clientscript (hoặc chỉ đường dẫn chính xác trong đoạn code bên dưới). - Open file adminfuntions.php tìm đoạn: / * Prints the page footer, finishes Gzip encoding and terminates execution */ function print_cp_footer() { Thêm vào bên dưới: // Begin HIM Editor for Admin Control Panel echo(" "); // End HIM Editor for Admin Control Panel (Chú ý là nếu bạn ko muốn upload file him.js vào thư mục clientscript thì phải chọn đường dẫn chính xác để gọi file him.js ở đây đường dẫn sẽ là: src=\" /him.js\" ) - Save file adminfuntions.php và upload lại lên host. Kết thúc phần nhúng bộ gõ. 18)CoDe Click Vào Link Và Đặt Web Bạn Làm Trang Chủ Trên IE <a target="blank" <a style="text-decoration: none; " onclick="this.style.behavior='url(#default#homepag e)';
  70. this.setHomePage(' " href=" Web Cua Bạn "> 19)Code Ko Cho Save Web 20)Code khi tắt web thì hiện thông báo [code] Bom Pr0 21)Code Danh Mục tìm kiếm = Google
  71. 22)Một Calendar đẹp
  72. Put the code into the BODY of your HTML document > <! Begin monthnames = new Array( "January", "Februrary", "March", "April", "May", "June", "July", "August", "September", "October", "November",
  73. "Decemeber"); var linkcount=0; function addlink(month, day, href) { var entry = new Array(3); entry[0] = month; entry[1] = day; entry[2] = href; this[linkcount++] = entry; } Array.prototype.addlink = addlink; linkdays = new Array(); monthdays = new Array(12); monthdays[0]=31; monthdays[1]=28; monthdays[2]=31; monthdays[3]=30; monthdays[4]=31; monthdays[5]=30; monthdays[6]=31; monthdays[7]=31; monthdays[8]=30; monthdays[9]=31; monthdays[10]=30; monthdays[11]=31; todayDate=new Date(); thisday=todayDate.getDay(); thismonth=todayDate.getMonth();
  74. thisdate=todayDate.getDate(); thisyear=todayDate.getYear(); thisyear = thisyear % 100; thisyear = ((thisyear 7) startspaces-=7; startspaces = thisday - startspaces + 1; if (startspaces "); document.write(" " + monthnames[thismonth] + " " + thisyear + " "); document.write(" "); document.write(" Su "); document.write(" M "); document.write(" Tu "); document.write(" W "); document.write(" Th "); document.write(" F "); document.write(" Sa "); document.write(" "); document.write(" "); for (s=0;s<startspaces;s++) {
  75. document.write(" "); } count=1; while (count "); for (c=0;c "); linktrue=true; } } } if (count==thisdate) { document.write(" "); } if (count "); }
  76. if (linktrue) document.write(" "); document.write(" "); count++; } document.write(" "); document.write(" "); startspaces=0; } document.write(" "); // End >