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

来源:互联网 发布:mac打开侧边栏快捷键 编辑:程序博客网 时间:2024/05/16 01:28

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

连接时设备置的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