I want to open new window in new process/context in chrome, (Im not sure if it possible with window.open but with the following example its working ) currently if it was regular window you can check with the following example and to see if the pop-up blocker is enabled
ar newWin = window.open(url);
if(!newWin || newWin.closed || typeof newWin.closed=='undefined')
{
//POPUP BLOCKED
}
but I want to open the new window in new process without window.open like following
var prod = document.getElementById("myElement");
var aTag = document.createElement('a');
aTag.setAttribute('href',"http://cnn.com");
//THIS TWO LINES do the job
aTag.setAttribute('rel',"noreferrer");
aTag.setAttribute('target',"_blank");
prod.appendChild(aTag);
aTag.click();
prod.removeChild(aTag);
used with this reference: http://news.softpedia.com/news/Force-Google-Chrome-to-Open-Links-in-New-Processes-128962.shtml
from the post to open new tab in new context you should use:
aTag.setAttribute('rel',"noreferrer");
aTag.setAttribute('target',"_blank");
While this is working, sometimes the new window/tab is blocked with the pop-up blocker,I just want to know this and inform the user internally that the new window is blocked and please enable it ...which option do I have?
My requirements are this:
- Open window in new process/context
- if the popup blocker is blocked notify the user
How it can be done ?
UPDATE
I need it since when you click to open new window from existing window and the second window is opened and you return to the first/source window and you want to do something it's blocked!
To simulate this you can create this simple file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BlockTAB</title>
</head>
<br/>
<br/>
<button onclick="windowOpen('http://cnn.com')">window open native</button>
<br/>
<br/>
<button onclick="windowOpen('http://google.com')">sample</button>
<script>
function windowOpen(url){
window.open(url);
}
</script>
</html>
Now do the folloiwng
- Run the program (the html file), this open the CNN tab
- inspect the CNN tab and put break point on it (in the source tab you can find the javascript, put it in any place you choose),until it stops(you need to refresh the page until you see the debugger stops...
- Now go back to the first tab were the two buttons is and you see that it is blocked, you cannot do anything like click and etc...
How to handle open the new tab without blocking the first/source tab?
UPDATE 2
There is a way to simulate the pop-up blocker if it's not happen with the code with
aTag.setAttribute('rel',"noreferrer"); aTag.setAttribute('target',"_blank");
add this following code the previous example
<script src="https://cdn.jsdelivr.net/bluebird/3.4.5/bluebird.js"></script>
<br/>
<br/>
<button onclick="EnabledPPB('http://cnn.com')">Blocker</button>
function delayFN(url) {
Promise.delay(500)
.then(function() {
var newWin = window.open(url);
})
}
function EnabledPPB(url) {
Promise.delay(100)
.then(function() {
delayFN(url);
})
}