zoukankan      html  css  js  c++  java
  • 跨域产生的原因,及判断条件

    1、同源策略

    同源策略是浏览器的行为,是为了保护本地数据不被JavaScript代码获取回来的数据污染,因此拦截的是客户端发出的请求回来的数据接收,即请求发送了,服务器响应了,但是无法被浏览器接收

    参数原因:

    由 Netscape 公司 1995 年引入浏览器,它是浏览器最核心也最基本的安全功能,现在所有支持 JavaScript 的浏览器都会使用这个策略。如果缺少了同源策略,浏览器很容易受到 XSS、 CSFR 等攻击。

    2、跨域

    跨域就是非同源策略请求。

    产生原因:请求方式、域名、端口 其中任意一个不同即为跨域:

    url 说明 是否跨域

    http://www.abc.com:80/index.html

    http://www.abc.com:80/index.asp

    同请求方式

    同域名

    同端口

    http://www.abc.com:80/index.html

    http://www.abc.com:80/posts/index.html

    同请求方式

    同域名

    同端口

    http://www.abc.com:80/index.html

    http://www.abc.com:8080/index.html

     

    同请求方式

    同域名

    不同端口

     是

    http://www.abc.com:80/index.html

    https://www.abc.com:80/index.html

     

    不同请求方式

    同域名

    同端口

     是

    http://www.abc.com:80/index.html

    http://wap.acb.com:80/index.asp

     

    同请求方式

    不同域名

    同端口

     是
     

    http://www.abc.com:80/index.html

    http://www.doc.abc.com:80/index.html

     

    同请求方式

    不同域名

    同端口

     是
     

    http://www.abc.com:80/index.html

    http://192.168.1.2:80/index.html

     

    同请求方式

    不同域名

    同端口

     是

    那么为什么有的网页还能各种跳转呢?

    原因是:
    <ink>、< script>、<img>、< frame>等这些标签具有跨域特性,可以直接访问

  • 相关阅读:
    如何在ASP.NET中使用div弹出窗口
    How to avoid error "LNK2001 unresolved external" by using DEFINE_GUID
    一个JavaScript实现的幻灯片程序分析
    Systems Thinking in Project Management
    CSS
    How To Clear Floats Without Structural Markup
    Public Symbols and Private Symbols
    DOM and CSS positioning
    JavaScript对象模型执行模型
    JavaScript 操作图片
  • 原文地址:https://www.cnblogs.com/easyidea/p/14365467.html
Copyright © 2011-2022 走看看