我正在使用window.open在新窗口中打开一个页面,但这被浏览器阻止,它要求用户允许弹出窗口有任何其他方式打开一个新窗口,其他人将使用浏览器不会阻止的网站
我的代码
string url = "../Printticket.aspx";
string fullURL = "window.open('" + url + "', '_blank', 'height=600,width=1000,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,titlebar=no' );";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
答案 0 :(得分:1)
浏览器阻止弹出窗口,因为您像大多数垃圾邮件网站一样使用JavaScript打开新窗口。
您可以返回带有链接的简单页面,而不是使用JavaScript,在新窗口中打开票证。当用户有意点击链接时,它不会被阻止。
<html>
...
<div>
Thank you for your purchase. You can print your ticket <a href='www.example.com/Printticket.aspx' target='_blank'>here</a>
</div>
...
</html>