在使用iframe的时候,希望在框架内进行操作之后实现整个页面的刷新,起初使用window.location.reload()方法
if(res.success){
window.location.reload(); //只是单层刷新
}else{
alert(res.Msg);
}
但是发现只是iframe框架做了跳转,而外层页面没有刷新,并没有实现想要的功能,因此我们需要操作上层页面,更改代码为
if(res.success){
parent.location.reload(); //父级页面刷新
}else{
alert(res.Msg);
}
如果使用了层层嵌套,则使用top.location.reload()方法,是做最顶层刷新。