问题描述
我想在chrome中的新进程/上下文中打开新窗口(我不确定是否可以使用window.open,但下面的例子工作)当前,如果它是常规窗口可以检查下面的例子,看看是否启用了弹出窗口拦截器。
ar newWin = window.open(url) ;
if(!newWin || newWin.closed || typeof newWin.closed =='undefined')
{
// POPUP BLOCKED
}
但我想在新进程中打开新窗口,而不需要window.open
var prod = document.getElementById(myElement);
var aTag = document.createElement('a');
Tag.setAttribute('href',http://cnn.com);
//这两行完成工作
Tag.setAttribute('rel',noreferrer);
aTag.setAttribute('target',_ blank);
prod.appendChild(aTag);
Tag.click();
prod.removeChild(aTag);
与此引用一起使用: / p> 当这个工作正常时,有时候新的窗口/标签会被弹出窗口拦截器阻止,I只是想知道这一点,并通知内部用户新窗口被阻止,请启用它...我有哪些选项? 我的要求是 如何完成? / p> 更新 我需要它,因为当您点击以从现有的窗口,第二个窗口打开,你回到第一个/源窗口,你想做一些它的阻止! 为了模拟这个你可以创建这个简单的文件 现在请执行以下操作: 如何在不阻止第一个/源标签的情况下处理新标签? 更新2 有一种方法可以模拟弹出式窗口拦截器, aTag.setAttribute('rel',noreferrer); 将以下代码添加到前面的e中xample 不确定要打开新窗口或新程序,所以也许我会同时回答。 如果你字面意思是你想确保Chrome开始一个新的进程,在JavaScript中没有办法做到这一点,甚至没有你用 在Chrome浏览器中使用新进程而不是每个选项卡的新线程的更多参考资料 如果您想确保您的用户在新窗口中打开您的消息,那么使用 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 but I want to open the new window in new process without window.open like following 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: 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: 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 Now do the folloiwng 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 Not very sure do you want to make sure to open a new window or new process, so maybe I will answer both. If you literally means you want to make sure Chrome starts a new process, there is no way to do that in Javascript, not even the code you shown with More reference on Chrome using new process instead of new thread for each tab. If you want to make sure your user is opening your message in a new window, the one with 这篇关于检查弹出窗口阻止程序在打开新选项卡时是否变亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
http://news.softpedia.com/news/Force-Google-Chrome在新的上下文中打开新标签,你应该使用:
aTag.setAttribute('rel',noreferrer);
aTag.setAttribute('target',_ blank);
$ b
<!DOCTYPE html>
< html lang =en>
< head>
< meta charset =UTF-8>
< title> BlockTAB< / title>
< / head>
< br />
< br />
< button onclick =windowOpen('http://cnn.com')>窗口打开本地< /按钮>
< br />
< br />
< button onclick =windowOpen('http://google.com')>样本< / button>
< script>
function windowOpen(url){
window.open(url);
}
< / script>
< / html>
aTag.setAttribute('target',_ blank);
< script src =https://cdn.jsdelivr.net/bluebird/3.4.5/bluebird.js >< /脚本>
< br />
< br />
< button onclick =EnabledPPB('http://cnn.com')>阻止器< /按钮>
函数delayFN(url){
Promise.delay(500)
.then(function(){
var newWin = window.open(url);
$)
}
函数EnabledPPB(url){
Promise.delay(100)
.then(function(){
delayFN (url);
})
}
window.open
显示的代码。但是,由于Chrome为每个标签打开了一个新流程,因此只要用户使用Chrome,就可以安全地使用新的流程。另一方面,检查用户正在使用的浏览器是可能的。虽然你的用户可能仍然伪造用户代理(即浏览器),但它应该足够内部使用。
window.open
是唯一的选择。您可以通过添加事件侦听器来触发 window.open
,或者仅使用HTML中的 onclick
属性。有没有办法单独使用HTML,并且当你已经找到一种方法来使用javascript时,应该没有理由搜索答案?ar newWin = window.open(url);
if(!newWin || newWin.closed || typeof newWin.closed=='undefined')
{
//POPUP BLOCKED
}
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);
aTag.setAttribute('rel',"noreferrer");
aTag.setAttribute('target',"_blank");
<!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>
<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);
})
}
window.open
. However, as Chrome is opening a new process for every tab, it is safe to assume your message is in a new process as long as your user is using Chrome. Checking what browser your user is using, on the other hand, is possible. Although your user may still fake the user agent (i.e. the browser), it should be quite enough for internal use.window.open
is the only option. You may trigger window.open
by adding event listener or simply use the onclick
attribute in HTML. There is no way to do with HTML alone, and there should be no reason to search for answer when you have already found a way to do that with javascript?