打开jsp页面onClick会打开框架内的页面

时间:2014-07-08 11:20:47

标签: javascript html css css3 twitter-bootstrap

enter image description here

上面的导航栏是npt.jsp&以下是框架。 点击按钮viewProfile onc我试图打开主页即root.jsp,而不是打开hte页面打开框架内的页面。 我附上了截图。请帮助我

 <body>
 <ul class="nav navbar-nav navbar-right">
          <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown"><div       id="session">
              <ul class="dropdown-menu">
                <li><a href="mytestdata.jsp" target="frame">My TestData</a></li>
                <li><a href="myprofile.jsp" target="frame">My Profile</a></li>
                </ul>
            </li>
 <iframe name="frame" src="npt.jsp"></iframe>\

点击myprofile在框架内打开它的锚标记,但在MyProfile页面中,当我点击按钮时(在点击主页上,在框架内打开 NOT

Myprofile代码:

    <div class="col-xs-12 col-sm-4">
                            <h2><strong>  </strong></h2>                    
                            <p><small>Followers</small></p>
                            <button class="btn btn-success btn-block"><span class="fa fa-plus-circle"></span> Follow </button>
                        </div><!--/col-->
                        <div class="col-xs-12 col-sm-4">
                            <h2><strong></strong></h2>                    
                            <p><small>Following</small></p>
                            <button class="btn btn-info btn-block" onclick="openPage('root.jsp')"><span class="fa fa-user"></span> View Profile </button>
                        </div><!--/col-->
                        <div class="col-xs-12 col-sm-4">
                            <h2><strong></strong></h2>                    
                            <p><small>Snippets</small></p>
                            <button type="button" class="btn btn-primary btn-block"><span class="fa fa-gear"></span> Options </button>  
                        </div><!--/col-->
                    </div><!--/row-->
              </div><!--/panel-body-->
          </div><!--/panel-->
<script>
function openPage(pageURL){
    window.location.href = pageURL;
}
</script>

1 个答案:

答案 0 :(得分:2)

<A HREF="profile.jsp" TARGET="_parent">View Profile</A>

<A HREF="profile.jsp" TARGET="_top">View Profile</A>

如果您使用的是javascript:

window.top.location.href = "profile.jsp"; 

在你的情况下,它将是:

<button class="btn btn-info btn-block" onclick="openPage('root.jsp')"> <script> function openPage(pageURL){ window.top.location.href = pageURL; } </script>