上面的导航栏是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/