简体   繁体   English

我如何在C#ASP.Net应用程序中打开弹出窗口而不用Chrome静默阻止它?

[英]How do i open popup window in C# ASP.Net application without Chrome silently blocking it?

I can't use RegisterStartupScript('window.open...), because Chrome blocks the popup without even informing the user. 我无法使用RegisterStartupScript('window.open ...),因为Chrome会阻止弹出窗口,甚至不会通知用户。

I can't use "onclientclick=window.open(..." in the markup, because I have to invoke code in the button click event handler before opening the popup window. 我不能在标记中使用“ onclientclick = window.open(...”),因为在打开弹出窗口之前,我必须在按钮单击事件处理程序中调用代码。

I can't expect every user of the website to add the site as an exception in Google Chrome's popup blocker, since they'll assume it's an error on the website and not with the popup blocker. 我不能期望网站的每个用户都将网站添加为Google Chrome弹出窗口阻止程序的例外,因为他们会认为这是网站上的错误,而不是弹出窗口阻止程序。

So what other options do I have? 那我还有其他选择吗?

Although the implementations are different, in general modern browsers will only allow popups in response to a user action, so trying to spawn a window from an ordinary script will be something most browsers will try to prevent. 尽管实现方式不同,但通常现代浏览器只允许弹出窗口来响应用户的操作,因此大多数浏览器都将尝试阻止从普通脚本中生成窗口。

If there were a workaround for this it would be like turning the clock back about 10 years to popup hell. 如果有解决方法,这就像将时钟倒回大约10年以弹出地狱。

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

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