日期:2014-05-16 浏览次数:20397 次
<mce:script type="text/javascript"><!-- Var sUrl="http://Jipiao.taobao.com/proxy.do"; //本域下代理地址 var callback = { success: function(res) { alert(res.responseText); }, failure: function(res) { alert('failure');}, argument:{} } YAHOO.util.Connect.asyncRequest('GET', sUrl, callback, null); // --></mce:script>
Public class Proxy extends …….{ ..doGet(……..){ HttpClient client=……; GetMethod get=new GetMethod("www.baidu.com/xxxxx.do");//访问域B的链接 int statusCode = client.executeMethod(get); if (statusCode != HttpStatus.SC_OK) { byte[] responseBody = get.getResponseBody(); String res=new String(responseBody); Httpresponse.getWriter().write(res);//将数据返回给域A } } }
<html> <head> <mce:script id="remoteScript" type="text/javascript" src=""/><!-- <head> <body> <script type="text/javascript" > Var remoteScript=document.getElementById("remoteScript"); remoteScript.src="www.baidu.com/xxxxx.do";//域B的链接 alert(remote.test);//使用域B返回的JSON数据 alert(f[0]); // --></mce:script> </body> </html>
<html> <head> <head> <body> <mce:script type="text/javascript" ><!-- Document.domain="taobao.com"; Var remoteHtml=document.getElementById("remoteHtml"); remoteHtml.src="promotion.taobao.com/xxxx.htm";//这里访问域B的链接 var document=remoteHtml.ContentDocument; //这里就可以使用document来操作域B中页面xxx.htm的数据了 // --></mce:script> <iframe id="remoteHtml" src="" style="diapay:none" mce_style="diapay:none"/> </body> </html>