JS左则菜单跳转问题(window.location.href )

点击左侧菜单时,能够进入到对应的操作页面,右侧操作区,

连接时设备置的target为contentName,但是每次点击时,都没有在目标的frame中打开,找了半天,原来是左侧菜单监听单击事件的方法处理中调用的是window.location.href = $(this).children("a").attr("href"),导致而页面直接在当前的窗口中打开,target没有声效. 

<div id="framecontentLeft">
   <div class="jquery-accordion-menu" id="jquery-accordion-menu">
      <ul id="demo-list">
         <li class="active"><a href="CategoryList" target="contentName"><i class="fa fa-home"></i>Home</a></li>
         <li><a href="#"><i class="fa fa-glass"></i>Events </a></li>
         <li><a href="#"><i class="fa fa-file-image-o"></i>Gallery </a><span class="jquery-accordion-menu-label">

最后解决方案,在左侧菜单的单击事件中使用window.parent.{framename}.location.href方法,代码如下,后面成功解决。如果有其它更好的方案,请告知,不胜感谢!!!
if ($(this).children("a").attr("href")=="#"){
   window.location.href = $(this).children("a").attr("href")
} else {
    window.parent.contentName.location.href = $(this).children("a").attr("href")
}


测试效果如下图所示:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<%@ include file = "jsp/utils/menu.jsp" %> <%@ include file = "jsp/static/setMenu.js" %> <%@ include file = "jsp/utils/baseUrl.jsp" %> // 用户登出 <%@ include file = "jsp/static/logout.jsp" %> $(document).ready(function () { //我的后台,session信息转移 if (window.localStorage.getItem("Token") != null && window.localStorage.getItem("Token") != 'null') { if (window.sessionStorage.getItem("token") == null || window.sessionStorage.getItem("token") == 'null') { window.sessionStorage.setItem("token", window.localStorage.getItem("Token")); window.sessionStorage.setItem("role", window.localStorage.getItem("role")); window.sessionStorage.setItem("accountTableName", window.localStorage.getItem("sessionTable")); window.sessionStorage.setItem("username", window.localStorage.getItem("adminName")); } } $('.dropdown-toggle .hidden-xs').html(window.sessionStorage.getItem('username')) $('.copyright').html('欢迎使用' + projectName) var token = window.sessionStorage.getItem("token"); if (token == "null" || token == null) { alert("请登录后再操作"); window.location.href = ("jsp/login.jsp"); } setMenu(); if(window.sessionStorage.getItem('role') != '管理员'){ var accountTableName = window.sessionStorage.getItem('accountTableName'); $('#myinfo').attr('href', baseUrl + 'jsp/modules/' + accountTableName + '/add-or-update.jsp'); http(accountTableName+'/session','GET',{},(res)=>{ if(res.code == 0){ window.sessionStorage.setItem('id',res.data.id); window.sessionStorage.setItem('onlyme',true); } }); } });
05-30

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值