javascript基础十(知识点类js中的跨域)
2016-04-22 18:54
525 查看
/** * 跨域:在不同的域名下进行数据交互 */ ajax: XMLHttpRequest(); //不能跨域 // 可以设置 1:document.domain = 'a.com'; 2:服务器代理: XMLHttpRequest 代理文件 3:script标签 :jsonp 4:location.hash 5:window.name (和上面本质相同) 6:flash 7:html5 postMessage jsonp : jspn + padding(填充) box({name : 'haha'}) function box(json){ alert(json.name); //haha } //引用js的方法 function createJs(url){ var oScript = document.createElement('script';) oScript.type = 'text/script'; oScript.URL = url; document.getElementsByTagName('head')[0].appendChild(oScript); } createJs('json.js?callback=fn'); function fn(json){ alert(json.name); }
相关文章推荐
- 看到两篇不错的jstack分析文章
- JSON快速入门指南
- QT自定义对象导入JavaScript脚本使用
- js 日常问题记录
- Understand JavaScript’s “this” With Clarity, and Master It
- javascript基础九(知识点类对象的引用)
- [JS教程] input checkbox 用js实现全选/不选
- JS内存泄漏排查方法(Chrome Profiles)
- Gson 与 fastJson 的使用
- 移动web学习--淘宝 flexible.js
- js数组去重
- js Cookie总结
- js Date总结
- Understand JavaScript Callback Functions and Use Them
- js DOM操作
- js 全国城市3级联动
- js 获取浏览器高度和宽度值(多浏览器)
- JavaScript中的CSS属性对照表
- JavaScript学习总结——this对象
- JavaScript Date(日期)对象详解