知识巩固——跨域,http与https

跨域

1、jsonp

  仅支持get请求,不支持post,因为实践中没用到过,真的不知道啊

  用法估计:服务器,比如js文件user('soc');

       客户端  html引用了上面的js  比如www.xx.com/user.js    并在此html有函数

        function user(name){  console.log(name);  } 

2、iframe

src     get

一般都是后端设置请求头的啊,java/php/node.js都是啊

  php——header("Access-Control-Allow-Origin: http://a.com"); 

  node——express

app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1');
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});

  java——...........................................

flash

iframe

h5 postmessage


原文地址:https://www.cnblogs.com/hhweb/p/7217515.html