網路的世界並沒有跳脫世界的規則
一樣需要知道他的位置(URL、統一資料定位符)
一樣需要知道他長怎樣(HTML、超文本標記語言)
一樣需要知道怎麼拿回來(HTTP、超文本傳輸協議)
統一資料定位符(Uniform Resource Locator)
格式:
[協定類型]://[伺服器位址]:[埠號]/[檔案路徑]?[查詢]#[片段id]
範例:
https://nisra.net:443/tmp/test.php?q=1#1
超文本傳輸協定(HyperText Transfer Protocol)
一種用來傳輸超媒體文件 (像是HTML文件) 的應用層協定
無狀態協定
方式 | 說明 |
GET | 取得目標資源 |
HEAD | 取得標頭 |
POST | 提交指定資源的實體 |
PUT | 替換目標資源 |
DELETE | 刪除目標資源 |
CONNECT | 和指定資源標明的伺服器之間,建立隧道 |
OPPTIONS | 取得資源通訊方式 |
TRACE | 用於測試或診斷 |
網址?參數名稱1=參數內容1&參數名稱2=參數內容2
將資料放在 message-body 進行傳送
傳遞上比較安全且傳遞的資訊可以比較多
封包攔截仍然能查詢到相關資訊
狀態碼 | 說明 |
---|---|
1xx | 訊息提示 |
2xx | 請求成功 |
3xx | 重新導向 |
4xx | 用戶端錯誤 |
5xx | 伺服器錯誤 |
紀錄使用者狀態資料
儲存在用戶端
Cookie 安全嗎?
把資訊存在 Server
透過session ID 跟 Server 要資料
User-agent: *
Disallow: /you_will_never_never_see_me
User-agent: *
Disallow: /you_will_never
另存新檔 (Ctrl + Shift + s )
HyperText Markup Language
超文本標記語言
讓瀏覽器讀取,並將其視覺化
標記語言
不是程式語言
<!DOCTYPE html>
<html>
<head>
<title>This is a title</title>
</head>
<body>
<p>Hello World!</p>
<!-- This is a comment -->
</body>
</html>
<!DOCTYPE html>
讓瀏覽器以HTML5渲染
用來敘述元素的相關性質
class 和 id
< ul >
< li > Coffee < /li >
< li > Milk < /li >
< /ul >
< ol >
< li > Coffee < /li >
< li > Milk < /li >
< /ol >
<form>
<input type="text" name="account">
<input type="password" name="password">
<input type="button" value="Submit" name="btn">
</form>
Cascading Style Sheets
衣服
<h2 style="color:red;">Red Text</h2>
<style type="text/css">
body {
background-color: black;
/* body tag 中的背景會變黑 */
}
.class-name {
color: red;
/* class-name 中的文字會變紅 */
}
#id-name {
color: blue;
/* id-name 中的文字會變藍 */
}
</style>
//.html 檔
<head>
<link rel="stylesheet" type="text/css" href="./css/XXX.css">
</head>
//.css 檔
body {
background: black;
}
高階直譯式語言
不是Java
寫在html檔案裡
<head>
<script>
<!-- Write your code here -->
</script>
</head>
<body>
<script>
<!-- Or write your code here -->
</script>
</body>
<head>
<script src="./js/XXX.js"></script>
</head>
function helloworld(){
console.log("Hello world!");
}
<script>
function add(x,y){
return x+y ;
}
</script>
單行註解以 // 開頭
多行註解以 /* 開頭,以 */ 結尾
console.log()
alert()
document.getElementById("id-name");
document.getElementByClassName("class-name");
document.getElementByTagName("tag-name");
var test = document.getElementById("id-name");
// 用 test 去接物件
test.innerText = "I've been changed"
// 最常使用,獲取或設置元素內的文字
test.innerHTML
// 獲取或設置元素包含的 HTML 標籤
(BMI = 體重 / 身高 (m)^2)
<a href="https://example.com/delete?id=3">刪除</a>
刪除
<a href="https://example.com/delete?id=3">開始測驗</a>
開始測驗
<form action="https://example.com/delete" method="POST">
<input type="text" name="id" value="3">
<input type="submit" value="開始測驗">
</form>
<form id="csrf" action="https://example.com/delete" method="POST">
<input type="text" name="id" value="3">
<input type="submit" value="開始測驗">
</form>
<script>
csrf.submit();
</script>