简体   繁体   English

打开新窗口,浏览器不会发出弹出窗口的警告

[英]open new window without the browser giving warning that is a popup

I am working on mvc2 and i'm trying to open from javascript in a new window something. 我正在研究mvc2,我试图在新窗口中打开javascript。 if i only use inside the js function window.open("action/action/"+param) like this 如果我只在js函数window.open(“action / action /”+ param)里面使用这样的话

function(){ 
 window.open("action/action/"+param);
} 

it works perfectly and the browser does not warn me that it is a new popup that i'm opening. 它完美运行,浏览器并没有警告我这是一个新的弹出窗口,我正在打开它。 But if i make an ajax call before the window.open, the browser tells me that is a new popup and if i accept it. 但是,如果我在window.open之前进行ajax调用,浏览器会告诉我这是一个新的弹出窗口,如果我接受它。

if (json.data && json.data.URL)
{
      window.open("action/action/"+param);//opens in a new window only if i accept popups 
}

how can i make it work without the browser considering it as popup? 如果没有浏览器将其视为弹出窗口,我怎么能让它工作?

您无法在用户点击某些内容或执行某项操作后立即“随机”弹出一个窗口,以便浏览器不会认为它是随机广告弹出窗口。

The window has to open as a direct result of the user's input. 窗口必须作为用户输入的直接结果打开。 For example, you could open a new window inside a click handler. 例如,您可以在单击处理程序中打开一个新窗口。 It's not full proof by any means, but it's one measure the browser can take to try and prevent unwanted popups. 它不是任何方式的完全证明,但它是浏览器可以采取的一种措施,以尝试防止不需要的弹出窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM