zoukankan      html  css  js  c++  java
  • js的跨域

    
    

    什么是JS的跨域?
    AJAX的XMLHttpRequest()
    子域和主域之间的情况
    服务器代理:XMLHttpRequest代理文件
    script标签:jsonp
    jsonp的含意:json+padding(内填充原理)
    js执行问题
    封装createJS函数
    动态生成函数名
    百度用使用的jsonp
    location.hash方式:iframe
    window.name方式
    flash方式
    html5的postMessage方式


    script标签:jsonp
    <!
    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script> //a.com //jsonp : json + padding(内填充) function createJs(sUrl){ var oScript = document.createElement('script');//动态创建script oScript.type = 'text/javascript'; oScript.src = sUrl; document.getElementsByTagName('head')[0].appendChild(oScript);//将script标签插入到head里面 } createJs('jsonp.js?callback=box');//box可为任何函数名称,他代表一个参数 function box(json){ alert(json.name); //miaov } </script> <!--<script type="text/javascript" src="jsonp.js"></script>--> </head> <body> </body> </html>
  • 相关阅读:
    对象与引用
    聊天室小程序
    tcp程序设计--客户端获取服务器输入输出流
    线程小例子--进度条
    线程小例子--控制输出
    ngnix反向代理
    使用vuex管理数据
    vue列表到详情页的实现
    vue-实现一个购物车结算页面
    localstorage本地存储的应用
  • 原文地址:https://www.cnblogs.com/angleyuli/p/4727161.html
Copyright © 2011-2022 走看看