gpt4 book ai didi

php - IE 通过弹出窗口阻止使用 jQuery 创建 pdf

转载 作者:行者123 更新时间:2023-12-01 06:00:30 25 4
gpt4 key购买 nike

我有一项服务可以生成 pdf 形式的自定义生日模板。用户拥有积分,当他单击按钮时,将执行 ajax 调用以获取创建的 pdf 文件的编号,然后使用 window.location 将 pdf 显示给用户。

在 Chrome 和 Firefox 中一切正常,但 IE 会通过一个通用的弹出栏来阻止 pdf 内容,询问用户的同意。当用户接受并单击"is"时,什么也不会发生,并且用户需要再次单击该按钮才能生效,而在后端,用户的积分已经被计算在内。

该网站的用户群主要是老年人,我不能让这种情况发生,因为根据谷歌分析,我的用户中有 60% 使用 IE。

这是电话:

$.ajax({
type: "POST",
url: "getNum.php",
dataType: "html",
data: {data: $.toJSON(birthday)},
success: function(data){

if (parseInt(data) <= 0){
$('#waitModal').modal('hide');
if(parseInt(data) != -10){
$('#signInModal').modal('show');
} else{
//no credit
}

}else{
window.location = "generateBirthdayCard.php?num="+parseInt(data)
}

}

这是显示 pdf 的脚本 (generateBirthdayCard.php):

if (!$_GET['num']) die("looking for ?url=http://www.....");
$num = trim(escapeshellarg($_GET['num']), "'");

//only if the requested refrence is an integer
if (is_numeric($num)){

$str = file_get_contents("/tmp/$num.pdf");
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($str));
header('Content-Disposition: inline; filename="custom-birthday-cards.pdf"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
die($str);

}

编辑:当使用 IE8 的开发者工具模拟 IE7 时,这种情况会发生在 IE8 和 IE7 中

最佳答案

当您说“没有发生任何事情”时,您是否检查过浏览器缓存中是否有新的 pdf 文件。我之前在下载文件时遇到过 IE 问题,但 IE 就是打不开它。

尝试使用 fiddler 来查看 ajax 方法是否正确响应 pdf。

您可以在同一浏览器中打开其他 PDF 吗?例如this one

关于php - IE 通过弹出窗口阻止使用 jQuery 创建 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11913998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com