使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法

使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法问题描述 nbsp nbsp nbsp nbsp 在做项目的过程中 需要完成修改密码后重新登录的功能 但是前端页面使用了 IFrame 的框架 修改页面内嵌在的 index html 中 重新登录的页面就内嵌到原来的页面中 问题如图所示 nbsp 修改密码成功后 nbsp 出现问题 修改密码页面跳转到的登录页面内置到了子页面中 nbsp 登录后出现了如下页面 nbsp 前端使用的是 AngularJs 后台使用的 sp

问题描述:

        在做项目的过程中,需要完成修改密码后重新登录的功能,但是前端页面使用了IFrame的框架,修改页面内嵌在的index.html中,

重新登录的页面就内嵌到原来的页面中。

问题如图所示:使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法

 

修改密码成功后:

使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法

 

出现问题,修改密码页面跳转到的登录页面内置到了子页面中

使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法

 登录后出现了如下页面:

使用iframe框架后的页面,执行跳转命令,目标页面内嵌至iframe的子页面的解决方法

 前端使用的是AngularJs,后台使用的springSecurity做的安全控制

原来代码:

password.html

 <a data-toggle="modal" class="btn btn-danger" ng-click="alterPassword(oldPassword,newPassword,password)">提交修改</a>

 

Service.js

//修改密码 this.alterPassword=function(oldPassword,newPassword){ return $http.get('../teacher/alterPassword.do?oldPassword='+oldPassword+'&newPassword='+newPassword); }

Controller.js

 //修改用户密码 $scope.alterPassword=function(oldPassword,newPassword,password){ if(newPassword!=password){ alert("两次密码输入的不一致!"); return; } teacherService.alterPassword(oldPassword,newPassword).success( function(response){ alert(response.message); //重新查询 location.href="../logout"; } ); }

 

修改后代码:

 //修改用户密码 $scope.alterPassword=function(oldPassword,newPassword,password){ if(newPassword!=password){ alert("两次密码输入的不一致!"); return; } teacherService.alterPassword(oldPassword,newPassword).success( function(response){ alert(response.message); //重新查询 /*location.href="../logout";*/ windows.parent.location.href="../logout"; } ); }

修改后,index.html的(主页面)直接跳转至的login.html页面

问题完美解决。

 

解决方法有两个:
(1)在<a> </a>标签中跳转,设置标签的目标属性为_parent;

<a target="_parent" href="../logout">安全退出</a>

(2)在js中使用window.location.href跳转,让父页面跟着一起跳转,即在window.location.href = url改为window.parent.location.href = url;(window可省略)

我根据项目采用的是第二种

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/233023.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号