<html>
<html>
<head>
</head>
<body id="body">
<form action="javascript:void(0);" id="exampleForm">
<input type="text" id="examplePass"/>
<input type="submit" />
</form>
</body>
<script>
document.getElementById("exampleForm").onsubmit = function(){
var passwordRegex =/^-?\d*$/;
if(!passwordRegex.test(document.getElementById("examplePass").value)){
console.log("Regex didn't match");
var notify = document.getElementById("notify");
if(notify === null){
notify = document.createElement("p");
notify.textContent = "error";
notify.id ="notify";
var body =document.getElementById("body");
body.appendChild(notify);
}
}
};
</script>
</html>
2013年10月28日星期一
2013年10月21日星期一
lab 14
get&post:
舉個例子,如果 HTTP 代表現在我們現實生活中寄信的機制,那麼信封的撰寫格式就是 HTTP。我們姑且將信封外的內容稱為 http-header,信封內的書信稱為 message-body,那麼 HTTP Method 就是你要告訴郵差的寄信規則。
假設 GET 表示信封內不得裝信件的寄送方式,如同是明信片一樣(感謝網友 Kevin 的建議,採用明信片來詮釋 GET),你可以把要傳遞的資訊寫在信封(http-header)上,寫滿為止,價格比較便宜。然而 POST 就是信封內有裝信件的寄送方式(信封有內容物),不但信封可以寫東西,信封內 (message-body) 還可以置入你想要寄送的資料或檔案,價格較貴。
使用 GET 的時候我們直接將要傳送的資料以 Query String(一種Key/Vaule的編碼方式)加在我們要寄送的地址(URL)後面,然後交給郵差傳送。使用 POST 的時候則是將寄送地址(URL)寫在信封上,另外將要傳送的資料寫在另一張信紙後,將信紙放到信封裡面,交給郵差傳送。
2013年10月14日星期一
lab 12
<html>
<body>
<img onmouseover="mOver(this)" onmouseout="mOut(this)"src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibsbXs7OGyYWYG3juKECB-cN8LCuGuwvwkeRdKdqHr2hLFTG0sBq-nV32yHgBbwiHM1JGR-j1Uv3ujZpocEmpcbg0IT8snlasM7Y4Ese6RyEWdBN2ISgQvTf73oZ67ezB5evIHtjklnss/s320/DSC_1795.JPG"</img>
<script>
function mOver(obj1)
{
obj1.setAttribute("src", "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibsbXs7OGyYWYG3juKECB-cN8LCuGuwvwkeRdKdqHr2hLFTG0sBq-nV32yHgBbwiHM1JGR-j1Uv3ujZpocEmpcbg0IT8snlasM7Y4Ese6RyEWdBN2ISgQvTf73oZ67ezB5evIHtjklnss/s320/DSC_1795.JPG")
}
function mOut(obj2)
{
obj2.setAttribute( "src", "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCrv2-shTRCpBQ2s04_VQU4TpZWCNnY1tVzN4oGFi8V0Mf2gOIRTNxgOHDc_9ftxjR2FfzKQsjqF06rENqogV0DSGJpGCutHUbuQn0je6vyc9gx6vxzX0rIIxOyTg5-aVPDPGe2ZDhK5HM/s320/DSC_1772.JPG")
}
</script>
</body>
</html>
lab 11
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>lab26</title>
<script>
function buildTable(){
docBody = document.getElementsByTagName("body").item(0)
myTable = document.createElement("TABLE")
myTable.id ="TableOne"
myTable.border = 1
myTableBody = document.createElement("TBODY")
for (i = 0; i < 10; i++){
row = document.createElement("TR")
for (j = 0; j < 10; j++){
cell = document.createElement("TD")
cell.setAttribute("WIDTH","50")
cell.setAttribute("HEIGHT","50")
textVal = i+"*"+j+"="+i*j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
}
myTableBody.appendChild(row)
}
myTable.appendChild(myTableBody)
docBody.appendChild(myTable)
}
window.onload = buildTable
</script>
</head>.
<body>
<br>
</body>
</html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>lab26</title>
<script>
function buildTable(){
docBody = document.getElementsByTagName("body").item(0)
myTable = document.createElement("TABLE")
myTable.id ="TableOne"
myTable.border = 1
myTableBody = document.createElement("TBODY")
for (i = 0; i < 10; i++){
row = document.createElement("TR")
for (j = 0; j < 10; j++){
cell = document.createElement("TD")
cell.setAttribute("WIDTH","50")
cell.setAttribute("HEIGHT","50")
textVal = i+"*"+j+"="+i*j
textNode = document.createTextNode(textVal)
cell.appendChild(textNode)
row.appendChild(cell)
}
myTableBody.appendChild(row)
}
myTable.appendChild(myTableBody)
docBody.appendChild(myTable)
}
window.onload = buildTable
</script>
</head>.
<body>
<br>
</body>
</html>
订阅:
博文 (Atom)




















