移动端模态框内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
相关产品推荐
相关产品推荐

