紀錄工作經驗、相關知識,解決技術相關問題。

HTML, 網站相關, 資訊相關

瀏覽器 同源策略 Same-origin policy – 簡單說明

同源策略 英文Same-origin policy ,主要是針對 Web瀏覽器跨域安全性的專有名詞。

同源策略可防止惡意腳本通過頁面修改等方式,使網頁訪問不再規範內的惡意檔案 or 敏感資訊。

同源策略的條件必須符合 :

  • 域名相同
  • 埠號相同
  • 協定相同

以上條件一項不符,均視為不符合同源策略。

以 https://domain.com/aaa.html?abc=1為例子,以下列舉範例,來判斷是否符合同源策略

URLOutcomeReason
https://domain.com/aaa.html?aaa/b.html同源
http://domain.com/aaa.html?abc=1不同源協定不同
https://sub.domain.com/aaa.html?abc=1不同源域名不同
https://domain.com:55/aaa.html?abc=1不同源埠號不同
https://domain.com/aaa?s=123同源
同源策略 – 範例說明

9 留言

  1. After reading your article, it reminded me of some things about gate io that I studied before. The content is similar to yours, but your thinking is very special, which gave me a different idea. Thank you. But I still have some questions I want to ask you, I will always pay attention. Thanks.

  2. After reading your article, it reminded me of some things about gate io that I studied before. The content is similar to yours, but your thinking is very special, which gave me a different idea. Thank you. But I still have some questions I want to ask you, I will always pay attention. Thanks.

  3. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

  4. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

  5. Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

  6. I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don’t know much about a certain place. Can you help me?

  7. I have read your article carefully and I agree with you very much. This has provided a great help for my thesis writing, and I will seriously improve it. However, I don’t know much about a certain place. Can you help me?

  8. Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

  9. Do you mind if I quote a couple of your articles as long asI provide credit and sources back to your website?My blog site is in the very same niche as yours and my users would certainly benefit from some of the information you present here.Please let me know if this okay with you. Thanks!

發表迴響