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.