Javascript中实现跨域访问的方法总结

http://developer.51cto.com/art/201102/245701.htm

http://www.iteye.com/topic/897253

http://edu.codepub.com/2010/1108/27003.php

 

1.使用jQuery的getScript方法跨域取得json数据 (JSONP)

http://www.cnblogs.com/Gaton/archive/2009/12/01/1614364.html

http://blog.ossxp.com/2010/02/462/

http://www.flash34.com/space/b2_1987

 

2.使用iframe实现跨域:

http://www.cnblogs.com/chyingp/archive/2010/08/23/1806260.html

http://hi.baidu.com/beluker/blog/item/0dc968ffc67cb149d6887df1.html

 

使用iframe时的注意点:

1.使用document.createElement('iframe')方法创建iframe, 把需要传递的参数写进uel:

    function iframeCallBack(xxx, yyy) {
        var iframe = document.createElement('iframe');
        iframe.style.border='0px';
        iframe.style.width ='0px';
        iframe.style.height='0px';
        iframe.src = url + "?xxx="+xxx+"&yyy="+yyy;
        document.body.appendChild(iframe);
    }

2.在iframe中可以使用 document.location.toString(); 把参数以字符串形式接回来。

然后通过split / substr 等方法把参数都还原回来。

 

3.在iframe页面中可以使用window.parent.method来直接调用主页面的method方法。

 

其他资料:

http://www.cnblogs.com/rainman/archive/2011/02/16.html

http://www.sdvil.com/html5/293

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值