Sc

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Sc as PDF for free.

More details

  • Words: 1,663
  • Pages: 12
6. một số đoạn javascript về ngày giờ Đây là một số đạon mã nguồn về ngày, giờ trên javascipt nó rất hữu dụng cho các bạn trong thiết kế web Đoạn mã 1: Ngày tháng. <Script Language = “Javascript”> var Thu = new Array(" chu nhat: "," thu hai: "," thu ba: "," thu tu: "," Thu nam: ", " thu sau: "," thu bay: "); var Today = new Date(); var day = Today.getDate(); var month = Today.getMonth(); var year = Today.getYear(); strday = day strmonth = month + 1 if (year < 2000) var year = year + 1900; if (day < 10) var strday = '0' + day if (strmonth < 10) var strmonth = '0' + strmonth document.write("Hom nay" + Thu[Today.getDay()] + strday + "/" + strmonth + "/" + year) Đoạn mã 2: Giờ giấc. <SCRIPT language = "Javascript"> function clock() { day = new Date(); hrNow = day.getHours(); mnNow = day.getMinutes(); scNow = day.getSeconds(); miNow = day.getTime(); if (hrNow == 0) { hour = 12; ap = " AM"; } else if(hrNow <= 11) { ap = " AM"; 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; } else { secs = scNow; } time = hour + ":" + min + ":" + secs + ap; document.form.button.value = time; self.status = time; // Giôø seõ theå hieän treân thanh Status Bar. setTimeout('clock()', 1000); } document.write("
"); clock(); Đoạn mã 3: Tạo một cuốn lịch. <SCRIPT LANGUAGE="JavaScript"> monthnames = new Array("Thaùng 1,","Thaùng 2,","Thaùng 3,","Thaùng 4,","Thaùng 5,", "Thaùng 6,","Thaùng 7,","Thaùng 8,","Thaùng 9,","Thaùng 10,","Thaùng 11,","Thaùng 12,"); 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(); thisdate=todayDate.getDate(); thisyear=todayDate.getYear(); thisyear = thisyear % 100; thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear)); if (((thisyear % 4 == 0) && !(thisyear % 100 == 0))||(thisyear % 400 == 0)) monthdays[1]++; startspaces=thisdate; while (startspaces > 7) startspaces-=7; startspaces = thisday - startspaces + 1; if (startspaces < 0) startspaces+=7; document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write("");

document.write("
"); document.write(""); document.write(""); document.write(""); document.write(""); for (s=0;s<startspaces;s++) { document.write(""); } count=1; while (count <= monthdays[thismonth]) { for (b = startspaces;b<7;b++) { linktrue=false; document.write(""); count++; } document.write(""); document.write("");

startspaces=0; } document.write("
<strong>"+monthnames[thismonth] + " " + thisyear + "
C.NT.2T.3T.4T.5T.6T.7
"); for (c=0;c"); linktrue=true; } } } if (count==thisdate) { document.write("<strong>"); } if (count <= monthdays[thismonth]) { document.write(count); } else { document.write(" "); } if (count==thisdate) { document.write(""); } if (linktrue) document.write(""); document.write("

"); Bạn đặt đoạn Js sau vào Tab để có chiếc đồng hồ xinh xắn luôn hiện cùng thanh cuộn của Web. <script language="JavaScript"> //Analog clock script- By Kurt ([email protected]) fCol='444444'; //face colour. sCol='FF0000'; //seconds colour. mCol='444444'; //minutes colour. hCol='444444'; //hours colour. Ybase=30; //Clock height. Xbase=30; //Clock width. H='...'; H=H.split(''); M='....'; M=M.split(''); S='.....'; S=S.split(''); NS4=(document.layers); NS6=(document.getElementById&&!document.all); IE4=(document.all); Ypos=0; Xpos=0; dots=12; Split=360/dots; if (NS6){ for (i=1; i < dots+1; i++){ document.write('
'+i+'
');} for (i=0; i < M.length; i++){

document.write('
');} for (i=0; i < H.length; i++){ document.write('
');} for (i=0; i < S.length; i++){ document.write('
');}} if (NS4){dgts='1 2 3 4 5 6 7 8 9 10 11 12';dgts=dgts.split(' ') for (i=0; i < dots; i++){ document.write('
'+dgts[i]+'
');} for (i=0; i < M.length; i++){document.write(' ');} for (i=0; i < H.length; i++){document.write(' ');} for (i=0; i < S.length; i++){document.write(' ');}} if (IE4){document.write('
'); for (i=1; i < dots+1; i++){document.write('
'+i+'
');} document.write('
') document.write('
'); for (i=0; i < M.length; i++){ document.write('
');} document.write('
') document.write('
');

for (i=0; i < H.length; i++){document.write('
');} document.write('
') document.write('
'); for (i=0; i < S.length; i++){ document.write('
');} document.write('
')} function clock(){time = new Date ();secs = time.getSeconds();sec = -1.57 + Math.PI * secs/30;mins = time.getMinutes();min = -1.57 + Math.PI * mins/30; hr = time.getHours();hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360; if (NS6){Ypos=window.pageYOffset+window.innerHeight-Ybase-25; Xpos=window.pageXOffset+window.innerWidth-Xbase-30; for (i=1; i < dots+1; i++){ document.getElementById("n6Digits"+i).style.top=Ypos15+Ybase*Math.sin(-1.56 +i *Split*Math.PI/180) document.getElementById("n6Digits"+i).style.left=Xpos15+Xbase*Math.cos(-1.56 +i*Split*Math.PI/180) } for (i=0; i < S.length; i++){document.getElementById("Nx"+i).style.top=Ypos+i*Ybase/4.1*Math .sin(sec); document.getElementById("Nx"+i).style.left=Xpos+i*Xbase/4.1*Math.cos( sec); } for (i=0; i < M.length; i++){ document.getElementById("Ny"+i).style.top=Ypos+i*Ybase/4.1*Math.sin( min); document.getElementById("Ny"+i).style.left=Xpos+i*Xbase/4.1*Math.cos( min); } for (i=0; i < H.length; i++){ document.getElementById("Nz"+i).style.top=Ypos+i*Ybase/4.1*Math.sin(h rs); document.getElementById("Nz"+i).style.left=Xpos+i*Xbase/4.1*Math.cos( hrs);}} if (NS4){Ypos=window.pageYOffset+window.innerHeight-Ybase-20;

Xpos=window.pageXOffset+window.innerWidth-Xbase-30; for (i=0; i < dots; ++i){ document.layers["nsDigits"+i].top=Ypos5+Ybase*Math.sin(-1.045 +i*Split*Math.PI/180) document.layers["nsDigits"+i].left=Xpos-15+Xbase*Math.cos(-1.045 +i*Split*Math.PI/180) } for (i=0; i < S.length; i++){document.layers["nx"+i].top=Ypos+i*Ybase/4.1*Math.sin(sec); document.layers["nx"+i].left=Xpos+i*Xbase/4.1*Math.cos(sec); } for (i=0; i < M.length; i++){ document.layers["ny"+i].top=Ypos+i*Ybase/4.1*Math.sin(min); document.layers["ny"+i].left=Xpos+i*Xbase/4.1*Math.cos(min); } for (i=0; i < H.length; i++){ document.layers["nz"+i].top=Ypos+i*Ybase/4.1*Math.sin(hrs); document.layers["nz"+i].left=Xpos+i*Xbase/4.1*Math.cos(hrs); }} if (IE4){Ypos=document.body.scrollTop+window.document.body.clientHeight -Ybase-20; Xpos=document.body.scrollLeft+window.document.body.clientWidthXbase-20; for (i=0; i < dots; ++i){ ieDigits[i].style.pixelTop=Ypos-15+Ybase*Math.sin(-1.045 +i *Split*Math.PI/180) ieDigits[i].style.pixelLeft=Xpos-15+Xbase*Math.cos(-1.045 +i *Split*Math.PI/180) } for (i=0; i < S.length; i++){ x[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(sec); x[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(sec); } for (i=0; i < M.length; i++){ y[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(min); y[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(min); } for (i=0; i < H.length; i++){ z[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(hrs); z[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(hrs); }} setTimeout('clock()',100);} clock(); //--> 13. Bói tình yêu! Bạn thêm dòng code sau:

Bạn hãy nháºp tên bạn và tên ngÆ°á»ン i "ấy" và o 2 ô ở dÆ°á»›i!

+ =

(Ä ミ ây chỉ là xem cho vui thà ´i,các bạn đừng quá tin nha)

-:0:- 12A Online -:0:-

<SCRIPT language=JavaScript>

<SCRIPT language=JavaScript1.2>


Related Documents

Sc
October 2019 68
Sc
November 2019 68
Sc
April 2020 48
Sc
November 2019 81
Sc
December 2019 67
Sc
August 2019 75