You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

移动端模态框内PDF无法显示,点击按钮无响应问题求助

PDF模态框移动端显示异常问题

PC端可正常在模态框中加载并显示PDF,但在移动端仅显示带有“Open”文本的按钮,点击该按钮后无任何响应。已在多款移动端浏览器中测试,均出现相同问题。

实现代码

async function frmMostrar(idPDF){
    $(cargador__).attr('style', 'display: flex;');
    await fetch(`/obtenerInformeFinalDrive`, {
        method: 'POST',
        body: JSON.stringify({ idPDF: idPDF }),
        headers: { "Content-Type": "application/json", "X-CSRF-TOKEN": xcsrftoken_ },
    })
    .then(response => {
        if (!response.ok) {
            throw new Error('No se pudo recuperar el PDF');
        }
        return response.blob();
    })
    .then(responseBlob => {
        const reader = new FileReader();
        reader.onload = () => {
            const byteArray = new Uint8Array(reader.result);
            const pdfBlob = new Blob([byteArray], { type: 'application/pdf' });
            const pdfUrl = URL.createObjectURL(pdfBlob);

            const iframe = document.createElement('iframe');
            iframe.src = pdfUrl;
            iframe.height = '100%';
            iframe.width = '100%';

            if (!alertify.modal_informe_final) {
                alertify.dialog("modal_informe_final", function() {
                    return {
                        main: function(message) {
                            this.message = message;
                        },
                        prepare: function() {
                            this.setContent(this.message);
                        }
                    };
                });
            }
            const modal = alertify.modal_informe_final(iframe).set({ onclosing:function(){}}).set({title: 'Informe final'}).maximize();
            const modalContainer = modal.elements.modal;
            modalContainer.classList.add('modal_informe_final');
        };
        reader.readAsArrayBuffer(responseBlob);
    })
    .catch(error => {
        console.error('Error al recuperar PDF:', error);
    });
    $(cargador__).attr('style', 'display: none;');
}

效果差异

  • 移动端:仅显示带有“Open”文本的按钮,点击后无任何响应
  • PC端:模态框内正常加载并完整显示PDF内容

内容的提问来源于stack exchange,提问作者Luis Estrada

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 17:52:33