Javascript Windows.open不在chrome 6中工作

Javascript Windows.open不在chrome 6中工作,javascript,google-chrome,Javascript,Google Chrome,我正在尝试使用window.open在新窗口(选项卡)中打开一个位置。它在铬合金中不起作用。首先,我尝试了window.open(url,name),这不起作用,但在其他浏览器中都能起作用。然后我用了这样的东西 var w = window.open("about:blank"); w.opener = null; w.document.location = url; 这会在同一个选项卡中打开url,但不会在单独的选项卡中打开。这样做 window.open( url, "_blank" );

我正在尝试使用window.open在新窗口(选项卡)中打开一个位置。它在铬合金中不起作用。首先,我尝试了window.open(url,name),这不起作用,但在其他浏览器中都能起作用。然后我用了这样的东西

var w = window.open("about:blank");
w.opener = null;
w.document.location = url;
这会在同一个选项卡中打开url,但不会在单独的选项卡中打开。

这样做

window.open( url, "_blank" );
记住,第二个参数类似于锚定标记的
target
属性

window.open( url, "_blank" );

记住,第二个参数类似于锚定标记的
目标属性。

您确定弹出窗口没有被阻止吗?大多数没有响应用户事件的弹出窗口将被阻止。我在控制台中键入window.open(“google.com”,“_blank”),我在url栏上找到了被阻止的窗口

你确定你的弹出窗口没有被阻止吗?大多数没有响应用户事件的弹出窗口将被阻止。我在控制台中键入window.open(“google.com”,“_blank”),我在url栏上找到了被阻止的窗口。在IE8中工作,当弹出窗口被阻止时在FF中失败

<html>
<head>
<script type="text/javascript">
if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
HTMLElement.prototype.click=function(){ // event by Jason Karl Davis
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
function loadAndClick(url,target) {
  var lnk = document.createElement("a");
  lnk.href=url;
  lnk.target=target||"_blank"
  lnk.id="myLink"
  lnk.onclick=function() {
    var w = window.open(this.href,this.target);
    return (w)?false:true;
  }
  document.body.appendChild(lnk);
  document.getElementById('myLink').click();
//  lnk.click();
}
window.onload=function() { // or call getURL("javascript:loadAndClick('http://www.google.com')");
  loadAndClick("http://www.google.com");
}  
</script>
</head>
<body>
</body>
</html>

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
HtmleElement.prototype.click=function(){//event by Jason Karl Davis
var evt=this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click',true,true,this.ownerDocument.defaultView,1,0,0,0,false,false,false,false,false,false,0,null);
本次调度事件(evt);
}
函数加载并单击(url、目标){
var lnk=document.createElement(“a”);
lnk.href=url;
lnk.target=target | |“_blank”
lnk.id=“myLink”
lnk.onclick=函数(){
var w=window.open(this.href,this.target);
返回值(w)?假:真;
}
文件.正文.附件(lnk);
document.getElementById('myLink')。单击();
//lnk.click();
}
window.onload=function(){//或调用getURL(“javascript:loadAndClick('http://www.google.com')");
加载并单击(“http://www.google.com");
}  

试试这个。在IE8中工作,当弹出窗口被阻止时在FF中失败

<html>
<head>
<script type="text/javascript">
if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
HTMLElement.prototype.click=function(){ // event by Jason Karl Davis
var evt = this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
this.dispatchEvent(evt);
}
function loadAndClick(url,target) {
  var lnk = document.createElement("a");
  lnk.href=url;
  lnk.target=target||"_blank"
  lnk.id="myLink"
  lnk.onclick=function() {
    var w = window.open(this.href,this.target);
    return (w)?false:true;
  }
  document.body.appendChild(lnk);
  document.getElementById('myLink').click();
//  lnk.click();
}
window.onload=function() { // or call getURL("javascript:loadAndClick('http://www.google.com')");
  loadAndClick("http://www.google.com");
}  
</script>
</head>
<body>
</body>
</html>

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
HtmleElement.prototype.click=function(){//event by Jason Karl Davis
var evt=this.ownerDocument.createEvent('MouseEvents');
evt.initMouseEvent('click',true,true,this.ownerDocument.defaultView,1,0,0,0,false,false,false,false,false,false,0,null);
本次调度事件(evt);
}
函数加载并单击(url、目标){
var lnk=document.createElement(“a”);
lnk.href=url;
lnk.target=target | |“_blank”
lnk.id=“myLink”
lnk.onclick=函数(){
var w=window.open(this.href,this.target);
返回值(w)?假:真;
}
文件.正文.附件(lnk);
document.getElementById('myLink')。单击();
//lnk.click();
}
window.onload=function(){//或调用getURL(“javascript:loadAndClick('http://www.google.com')");
加载并单击(“http://www.google.com");
}  
创建重定向页面(例如redirect.aspx)

window.open('Redirect.aspx?URL=http://www.google.com","空白",;
从Redirect.aspx页面,重定向到QS中指定的URL

这对我来说是一种享受,因为Chrome阻止了我的新窗口。

创建一个重定向页面(例如redirect.aspx)

window.open('Redirect.aspx?URL=http://www.google.com","空白",;
从Redirect.aspx页面,重定向到QS中指定的URL


这对我来说是一种享受,Chrome阻止了我的新窗口。

Peter,这不起作用:(.我没有使用锚定标记,这是一个闪光,当单击时,url必须在新选项卡中打开。Chrome可能阻止了它。Peter,这不起作用:(.我没有使用锚定标记,这是一个闪光,当点击时,url必须在新选项卡中打开。然后,Chrome可能会阻止它。小弹出阻止图标跳过了我的眼睛。谢谢大家…:)小弹出阻止图标跳过了我的眼睛。谢谢大家…:)我没有让弹出窗口阻止程序忽略本地文件,即在/some-file.php打开文件仍会触发Chrome的弹出窗口阻止程序.Chrome v.20。我没有让弹出窗口阻止程序忽略本地文件,即在/some-file.php打开文件仍会触发Chrome的弹出窗口阻止程序.Chrome v.20。