js的跨域
2015-08-13 14:09
706 查看
什么是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>
相关文章推荐
- javascript数组与字符串方法
- js中各种距离clientWidth
- 区别js里面常用的random,ceil,round,floor
- Project facet jst.web.jstl has not been defined.
- javascript书籍
- js事件重复绑定问题
- js实现文本框宽度自适应文本宽度的方法
- 理解和运用JavaScript的闭包机制
- JavaScript:逻辑操作符“==”与“===”的区别
- JSP页面间的参数传递
- 实现js的trim()方法
- [js开源组件开发]模拟下拉选项框select
- 一个模拟ajax异步上传文件例子
- JSON.parse()和JSON.stringify()
- js弹出窗口
- javascript获取页面高度总结
- 运用JS设置cookie、读取cookie、删除cookie
- JS 只能输入数字和两位小数的JS
- js 页面无滚动条添加滚轮事件
- JavaScript语言基础知识1