192.168.14.69:http://192.168.14.69/payweb/iframe/default.aspx 客户端页面
通过js 动态输出iframe到localhost :default.aspx
js
Code
var links=window.document.getElementsByTagName('link');
var link='';
for(var i=0;i<links.length;i++)
{
if(links[i].rel.toLowerCase()=='stylesheet')
{
var href=links[i].href.split('../');
if(link!='')link+=',';
href=href[href.length-1];
link+=("http://"+document.domain+"/payWeb/"+href);
}
}
var paramter="mxid="+escape(document.getElementById("mxid").value);
paramter+="&";
paramter+="mxtime="+escape(document.getElementById("mxtime").value);
paramter+="&";
paramter+="mxoid="+escape(document.getElementById("mxoid").value);
paramter+="&";
paramter+="mxextend="+escape(document.getElementById("mxextend").value);
paramter+="&";
paramter+="amount="+escape(document.getElementById("amount").value);
paramter+="&";
paramter+="pm="+escape(document.getElementById("pm").value);
paramter+="&";
paramter+="pg="+escape(document.getElementById("pg").value);
paramter+="&";
paramter+="pgc="+escape(document.getElementById("pgc").value);
paramter+="&";
paramter+="pmobile="+escape(document.getElementById("pmobile").value);
paramter+="&";
paramter+="pname="+escape(document.getElementById("pname").value);
paramter+="&";
paramter+="pcerttype="+(document.getElementById("pcerttype").value);
paramter+="&";
paramter+="pidiograph="+escape(document.getElementById("pidiograph").value);
paramter+="&";
paramter+="name="+escape(document.getElementById("name").value);
paramter+="&";
paramter+="mobile="+escape(document.getElementById("mobile").value);
paramter+="&";
paramter+="email="+escape(document.getElementById("email").value);
paramter+="&";
paramter+="certtype="+escape(document.getElementById("certtype").value);
paramter+="&";
paramter+="idiograph="+escape(document.getElementById("idiograph").value);
paramter+="&";
paramter+="cardfrom="+escape(document.getElementById("cardfrom").value);
paramter+="&";
paramter+="omobile="+escape(document.getElementById("omobile").value);
paramter+="&";
paramter+="oemail="+escape(document.getElementById("oemail").value);
paramter+="&";
paramter+="oname="+escape(document.getElementById("oname").value);
paramter+="&";
paramter+="oaddr="+escape(document.getElementById("oaddr").value);
paramter+="&";
paramter+="digest="+escape(document.getElementById("digest").value);
paramter+="&";
paramter+="ownstyle="+escape(document.getElementById("ownstyle").value);
paramter+="&";
paramter+="userid="+escape(document.getElementById("userid").value);
paramter+="&";
paramter+="domain="+escape(document.domain);
paramter+="&";
paramter+="path="+escape(link);
if(document.getElementById("ownstyle").value=="F")
{
//直跳链接
document.location.href="http://localhost/payWeb/front/dlp/debitcard.aspx?"+paramter;
}
else
{
//嵌入页面
var temphtml="";
temphtml+="<IFRAME ID='BAIDUFRAME' BORDER='0' VSPACE='0' HSPACE='0' MARGINWIDTH='0' MARGINHEIGHT='0'";
temphtml+=" FRAMESPACING='0' FRAMEBORDER='0' SCROLLING='NO' WIDTH='1000' HEIGHT='600'";
temphtml+="src='http://localhost/payWeb/front/dlp/debitcard.aspx?"+paramter+"'";
temphtml+="></IFRAME>";
//alert(temphtml);
document.write(temphtml);
}
localhost:http://localhost/payweb/font/debitcard.aspx 被iframe嵌入页面
通过在debitcard.aspx 页面设置cookies到客户端机器 这时产生跨域操作,google搜索找到了一些解决方案,但都不成功,都是些asp 或 PHP的,基本上是添加p3p header头。没有具体提供.NET 的办法,这里从国外人的站点找到了准确的答案(难道中国没有人实际遇到吗?),添加HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");到要读写操作cookies的页面 ,其他的就和操作一个域一样了
.net 代码
Code
[Serializable]
public partial class front_dlp_ajax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string PM = Request.Params["PM"];
string PP = Request.Params["PP"];
string result = "false";
HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");
if (HttpContext.Current.Session[SessionKey.ORDER_ENTITY] != null)
{
Order_Entity oe = (Order_Entity)Session[SessionKey.ORDER_ENTITY];
if (oe != null)
{
oe.Pm = PM;
string[] ppvalue = PP.ToString().Split(',');
oe.Pg = ppvalue[0];
oe.Pgc = ppvalue[1];
HttpContext.Current.Session[SessionKey.ORDER_ENTITY] = oe;
#region 保存Cookies
HttpCookie cookies = new HttpCookie(SessionKey.INTIMEPAY_COOKIE);
cookies.Values[SessionKey.PM] = oe.Pm;
cookies.Values[SessionKey.PGC] = oe.Pgc;
cookies.Expires = DateTime.Now.AddDays(365);
//cookies.Domain = domain;
HttpContext.Current.Response.Cookies.Add(cookies);
#endregion
result = "true";
}
}
Response.Write(result);
Response.End();
}
}