大佬教程收集整理的这篇文章主要介绍了jquery – SCRIPT70:权限被拒绝在IE中访问iFrame,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
基本上我要做的是使用隐藏的iFrame模拟像文件上传的Ajax,因为我们必须支持旧版浏览器.当iFrame成功发布后,它的响应有一个div,其中包含我读过的JSON然后解析.来自JSON的数据用于向用户显示指示文件上载状态的消息,并通过向表添加行来将链接添加到页面.但是在IE中,chechUploadResponse函数似乎甚至没有触发.
使用Javascript:
$(document).ready(function() { $('#btnPrint').click(openPrintTimesheetWindow); $('#date').change(postBACk); $('#employee').change(postBACk); $('#client').change(postBACk); $('#btnUpload').click(uploadFilE); $("#uploadFrame").on("load",function () { $('#uploadFrame').contents().find('#userFile').change(uploadFileChanged); checkUploadResponse(); }); }); function postBACk() { $('#timesheetPrintFilter').submit(); } function uploadFileChanged() { $('#ajaxBusy').show(); $('#uploadFrame').contents().find('#uploadForm').submit(); } function uploadFile() { var employeEID = $('#init_employee').val(); var periodDate = $('#init_periodEndDate').val(); $('#uploadFrame').contents().find('#employeEID').val(employeEID); $('#uploadFrame').contents().find('#periodEndDate').val(periodDatE); $('#uploadFrame').contents().find('#userFile').click(); } function checkUploadResponse() { var response = $('#uploadFrame').contents().find('#uploadResponse').text(); if (response != null && response != '') { var response = jQuery.parseJSON(responsE); if (response.status == "ERROR") { $("#dialog").html(response.messagE); $("#dialog").dialog({ buttons: { "OK": function() { $(this).dialog("close");}},title: "Error" }); } else { $("#dialog").html(response.messagE); $("#dialog").dialog({ buttons: { "OK": function() { $(this).dialog("close");}},title: "success" }); var url = response.url; var tsaid = response.tsaid; var name = response.name; var row = '<tr id="tsaid-' + tsaid + '">' + '<td width="80%" valign="top" align="left">' + '<a href="' + url + '">' + name + '</a>' + '</td>' + '</tr>'; $("#tsAttachment").append(row); } } $('#ajaxBusy').hide(); }
隐藏的iFrame:
<form id="uploadForm" name="uploadForm" action="timesheet-upload.PHP" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="3145728" /> <input type="hidden" name="employeEID" id="employeEID" value="" /> <input type="hidden" name="periodEndDate" id="periodEndDate" value="" /> <input type="file" name="userFile" id="userFile" /> </form>
以下是发布后隐藏的iFrame的示例响应
<div id="uploadResponse">{"status":"succesS","message":"Timesheet successfully uploaded","url":"uploads\/2013\/Aug\/1-49cd1c0217abf676505b349ec88bb5a42b1d5631e41232f08be3b0dced9f65e2.pdf","name":"How To Write A Cover Letter.pdf","tsaid":15}</div> <form id="uploadForm" name="uploadForm" action="timesheet-upload.PHP" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="3145728" /> <input type="hidden" name="employeEID" id="employeEID" value="" /> <input type="hidden" name="periodEndDate" id="periodEndDate" value="" /> <input type="file" name="userFile" id="userFile" /> </form>
建议的解决方案需要应用于jQuery库.
问题在这里解释:
https://connect.microsoft.com/IE/feedback/details/802251/script70-permission-denied-error-when-trying-to-access-old-document-from-reloaded-iframe
这里给出了解决方案:
另一个解决方案位于jQuery错误报告站点http://bugs.jquery.com/ticket/14535的此票据下
它由@L_22_17@muley发布,并且还提供了JSfiddle:http://jsfiddle.net/xqb4s/
// MY EDIT - this try/catch seems to fix IE 'permission denied' errors as described here: // http://bugs.jquery.com/ticket/14535 try{ document === document; //may cause permission denied } catch(err){ document = window.document; //resets document,and no more permission denied errors. }
在下面:
function Sizzle( SELEctor,context,results,seed )
以上是大佬教程为你收集整理的jquery – SCRIPT70:权限被拒绝在IE中访问iFrame全部内容,希望文章能够帮你解决jquery – SCRIPT70:权限被拒绝在IE中访问iFrame所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。