js jump level control: jump to parent-child difference in js:
Jump at the same level: window.location.href
Jump to parent level: parent.location
The page that jumps after the operation of the sub-page set by iframe is not in the sub-iframe, and it is required to use parent.location or parent.location.href in the parent's box.
Use window.location.href to jump in the current box
window.location.href, location.href are the jumps of this page
parent.location.href is the previous page jump
top.location.href is the outermost page jump
Use when manipulating elements: hierarchical relationship path manipulation (http://hubin19860118-163-com.iteye.com/blog/961413)
Hierarchical relationship of Window object, Parent object, Frame object, Document object and Form object: Windwo object → Parent object → Frame object → Document object → Form object.
Example:
A negotiation page is embedded in the system
<iframe src="http://localhost:8082/esteelChat/chat/offer/list/${conobjKey}/${customerKey}" width="101%" frameborder="0" height="600px" id="dataIframe">
</iframe>
It is controlled in the negotiation system. After the direct transaction is completed, it jumps to the parent level of the negotiation page, that is, the frame level of the A system.
/**
*Target transaction
*/
function applyInfoNew(objKey,ord_key,ORDPRICE_NO,NEW_PRICE,chatNum,ARTNFLAG,CNT_KEY){
var cnt_num=$("input[name='newNum']").val();
var orderPrice=$("input[name='orderPrice']").val();
jQuery.ajax({
async:true,
url:webUrl+"/chat/offer/buyInfo?cnt_price="+NEW_PRICE+"&conobj_key="+objKey+"&cnt_num="+chatNum,
cache:false,
timeout:10000,
datatype:"json",
success:function(data){
if(data.status=="1"){
alert(data.msg);
return;
}else{
//alert(2);
if (confirm("Do you confirm the deal?")) {
var CONTRADE_KIND = $("input[name='contradeKind']").val();
//alert(CONTRADE_KIND);
//document.form2.action=path+"/negotiate!applyNew.do?urlType=dicker&objKey="+objKey+"&conOrdPriceBean.ORD_KEY="+ord_key+"&conOrdPriceBean.ORDPRICE_NO="+ORDPRICE_NO+"&conOrdPriceBean.CONTRADE_KIND="+CONTRADE_KIND;
//document.form2.submit();
$.ajax({
url:webUrl+"/chat/offer/applyNew?urlType=dicker&objKey="+objKey+"&ord_key="+ord_key+"&ORDPRICE_NO="+ORDPRICE_NO+"&CONTRADE_KIND="+CONTRADE_KIND,
type:"post",
cache:false,
async:true,
dataType:"json",
data:$("#form2").serialize(),
success: function (ret) {
if(ret.status=="1"){
//alert(ret.status);window.location.href
parent.location="http://localhost:8081/web/conObj/buyDetail.do?txt_conobj_key="+objKey+"&txt_contrade_kind="+CONTRADE_KIND+"&pick_types=A&jianjibuynum=0&order_prices="+orderPrice+"&cdListKeyArrayFront="+""+"&buyNum="+chatNum+"&ARTNFLAG="+ARTNFLAG+"&CNT_KEY="+CNT_KEY+"&msg="+encodeURIComponent(ret.msg);
//window.location.href=webUrl+"/web/conObj/buyDetail.do?txt_conobj_key="objKey+"&txt_contrade_kind="+CONTRADE_KIND+"&pick_types=A&jianjibuynum=0&order_prices="+orderPrice+"&cdListKeyArrayFront="+"";
//$.zd.alert("Prompt information","Congratulations you have made a deal",function(){
//parent.location=webUrl+"/conObj!buyPrint.do?urlType=dicker&CNT_KEY="+ret.msg;
//});
}else{
//alert(8);
alert (ret.msg);
parent.location="http://localhost:8081/web/conObj/buyDetail.do?txt_conobj_key="+objKey+"&txt_contrade_kind="+CONTRADE_KIND+"&pick_types=A&jianjibuynum=0&order_prices="+orderPrice+"&cdListKeyArrayFront="+""+"&buyNum="+chatNum+"&ARTNFLAG="+ARTNFLAG+"&CNT_KEY="+CNT_KEY+"&msg="+encodeURIComponent(ret.msg);
//$.zd.alert("Prompt information",ret.msg,function(){
//refreshInfoData();
//});
}
},
error:function(retMsg){
parent.location="http://localhost:8081/web/conObj/buyDetail.do?txt_conobj_key="+objKey+"&txt_contrade_kind="+CONTRADE_KIND+"&pick_types=A&jianjibuynum=0&order_prices="+orderPrice+"&cdListKeyArrayFront="+""+"&buyNum="+chatNum+"&ARTNFLAG="+ARTNFLAG+"&CNT_KEY="+CNT_KEY+"&msg="+encodeURIComponent(retMsg.msg);
//window.location.hre="http://localhost:8081/web/siteindex.do";
//refreshInfoData();
}
});
}else{
return false;
}
}
},
error:function(XMLHttpResuest,textStatus,errorThrown){}
});
/**if(confirm("Confirm with price "+NEW_PRICE+", deal?")){
var CONTRADE_KIND = $("input[name='CONTRADE_KIND']").val();
document.form2.action="${path}/NegotiateAction!applyNew.action?urlType=dicker&objKey="+objKey+"&conOrdPriceBean.ORD_KEY="+ord_key+"&conOrdPriceBean.ORDPRICE_NO="+ORDPRICE_NO+"&conOrdPriceBean.CONTRADE_KIND="+CONTRADE_KIND;
document.form2.submit();
}*/
}