Here is my code, and this code to open new tab and focus on it.
- If tab is not opened yet, I will open it with specify name.
- If tab is opened, I will focus on it by using window.focus();
Quick test: http://jsfiddle.net/u2jd2oLw/1/
Javascript Code
var tabs = [];
$('#btnOpenTab').on('click', function(){
openTab('http://google.com.vn', 'GG');
});
function openTab(url, tabNm) {
try {
if (tabs[tabNm]) {
tabs[tabNm].focus();
} else {
var mTab = window.open(url, tabNm);
tabs[tabNm] = mTab;
tabs[tabNm].focus();
}
} catch(e) {
alert(e.message);
}
}
HTML Code
<button id="btnOpenTab">Open Tab</button>
Actually, I check in IE11, it occurred that "Access is denied"
And I tried to turn off option: "Turn on Pop-up Blocker" by un-check CheckBox.
Do you have any suggestion?
Thanks!!
It's a security feature in Windows: http://support.microsoft.com/kb/979954
Here are a couple of work arounds to try:
http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/a250c431-9f09-441c-9b78-af067233ed78
Giving a child window focus in IE8
This will work once due to the security issues
It failed to run twice because once the page loads it is no longer same origin.
I tried with an iFrame, but Google blocks that too now