I am trying to open a url of my application in a new tab and when user clicks on same link, it will focus on the open tab. This works fine in chrome. IE its does not work. Does IE require any other piece of code?
<html>
<head>
<script type="text/javascript">
var childWindowTab;
function openTab() {
var pathName = '/myurl';
var tabExists = false;
if (childWindowTab) {
if (childWindowTab.location.pathname === pathName) {
if (!childWindowTab.closed) {
console.log(childWindowTab, childWindowTab.focus());
setTimeout(function() {
childWindowTab.focus();
});
tabExists = true;
}
}
}
if (!tabExists) {
childWindowTab = window.open(pathName + window.location.search, '_blank');
}
}
</script>
</head>
<body>
<a href="#" onclick="openTab()">opne tab</a>
</body>
</html>