admin管理员组文章数量:1516870
I need to open a new window on first click on link .
But not to open a new windows on clicks on same link after first click.
Is there any way to solve this problem through html or javascript.
Thanks Jyoti
I need to open a new window on first click on link .
But not to open a new windows on clicks on same link after first click.
Is there any way to solve this problem through html or javascript.
Thanks Jyoti
Share Improve this question edited Nov 2, 2010 at 11:46 aioobe 422k114 gold badges829 silver badges840 bronze badges asked Nov 2, 2010 at 11:25 JyotiJyoti 2,1153 gold badges27 silver badges30 bronze badges 1- why have you annotated your your question with JAVA tag? – Denys Kniazhev-Support Ukraine Commented Nov 2, 2010 at 11:36
4 Answers
Reset to default 7Replace '_blank' with another string, e.g. 'new_window' (don't use spaces)
On further clicks the link will be opened inside the window opened onto the first click.
See (4.) inside the specification: http://www.w3/TR/html4/present/frames.html#h-16.3.2
<script>
var check=0;
function lanuchWindow(page){
if(check==0){
OpenWin = this.open(page);
check=1;
}
}
</script>
html code to call script:
<a href="#" onclick='lanuchWindow('pageURL.htm')'>;Launch Window</a>
This might probably help you... It will launch window for 1st time and set it's variable check to 1 and when again the link is clicked condition turns false and hence no window is launched.
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function Launch(page) {
OpenWin = this.open(page, "mywin", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=550,height=250");
}
// End -->
</SCRIPT>
<a href="#" onClick="Launch(...)">click</a>
NOTICE: it won't work if the JS is disabled on Browser. thanks four ur reply, Andy E
<a id="foo" href="url" target="_blank">hello</a>
<script>
// add an onclick handler:
$("#foo").click(function(){
// Now remove the onclick handler so subsequent clicks don't fire it.
$(this).click(function(){});
// And set the target attribute so it opens in current window...
$(this).attr("target", "");
return true;
});
</script>
This is a better option than the ones listed above because it degrades nicely for people who don't have javascript, or want to use their middle mouse button to force opening in a new tab.
本文标签:
版权声明:本文标题:javascript - how not to open new window on clicks after first click on link <a href="abc.jsp" target=&a 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/web/1744397856a2604312.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论