How To Open Url To The Same Tab If Its Already Open In Browser
Solution 1:
you can always put a name in the target so it will always go to the same window/tab
<ahref="somerandomurl.com"target="mywindow">Contact Us<\a>
Its not possible to control this on Internet explorer. You can however change how IE behaves: -Internet Options -Tabs -Always open pop-ups in a new tab -Open links from other programs in: A new tab in the current window
target="_blank"
will always make sure it opens in a new window
http://www.w3schools.com/tags/att_a_target.asp
It will however refresh the page with the same url
You can have the link return a javascript window object and be able to return to the window anytime you want without refreshing the page
var newtab = null;
functionopenwindow(){
if (newtab==null) {
newtab = window.open("www.example.com");
} else {
newtab.focus();
}
}
<aonclick="openwindow()">click me</a>
Solution 2:
This solution will work if someone refresh the parent page also, it will close the child tab if that tab is already open on refresh of parent page. Javascript:
<script>var newtab = null;
window.open('', 'business-list', '').close();
functionopenwindow() {
if (!newtab || newtab.closed) {
newtab = window.open("/admin/business-list.aspx","business-list");
} else {
newtab.focus();
}
}
</script>
HTML:
<aonclick="openwindow()"style="cursor:pointer">Business List</a>
Post a Comment for "How To Open Url To The Same Tab If Its Already Open In Browser"