javascript - 打开一个jsp页面 onClick在框架内打开页面

标签 javascript html css twitter-bootstrap

enter image description here

上面的导航栏是npt.jsp & 下面是框架。 单击按钮 viewProfile 我试图打开主页,即 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>\

Onclicking myprofile its opening within the frame its an anchor tag , but in MyProfile page when I click the button (on click home page shld be opened NOT within the frame)

我的资料代码:

    <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>

最佳答案

<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>

关于javascript - 打开一个jsp页面 onClick在框架内打开页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24630487/

相关文章:

javascript - 根据用户选择输入编写 html 文本

javascript - 在容器 Kendo 窗口调整大小上动态更改 Kendo Grid 行的高度

javascript - 验证 3 个输入字段后按钮不会将我带到下一个 URL

javascript - html 的静音/取消静音图标

html - SVG 颜色只能在 firefox 中正确显示

css - 键盘打开时, ionic 标签不会隐藏

javascript - 在 Dojo 日期选择器中禁用 future 日期?

html - 在 div 中显示文本,但将其视为背景图像

javascript - 如何让类别字段变小

jquery - 如何在 html 中创建一个简单的视频库?