大佬教程收集整理的这篇文章主要介绍了jquery – 如何在iframe中加载请求标头之前设置它,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我能够获取我可以在firebug中观察到的加密文件,但我的iframe仍然显示非加密文件供下载.检查后我可以说iframe请求新的GET.
码
$.ajax({ url: "/tutorial.text",beforeSend: function(xhr) { xhr.setrequestHeader("passworD_HEADER",userPwd); },success: function() { $("#Hidden_iframe").attr("src",thiS.Url); } });
这在Internet Explorer上运行良好.我如何强制iframe使用可用资源而不是请求新的GET.
或者我如何在iframe中设置setrequestHeader或者我真的需要一个jQuery.Ajax来执行此任务是否有任何最好的方法来下载直接从服务器设置为附件文件的Content-Disposition标头.
// some initial data var url = '//enable-cors.org/img/cloud-download.svg'; var password = '123456'; // download url into arrayBuffer function download (url,password,cb) { var xhr = new XMLhttprequest(); xhr.open('GET',url,truE); xhr.responseType = 'arraybuffer'; // xhr.setrequestHeader('passworD_HEADER',password); xhr.onload = function () { cb(xhr.responsE); }; xhr.send(null); } // receive binary content of url // create blob link and click on it download(url,function (arrayBuffer) { var file = new File([arrayBuffer],'some filename'); var a = document.createElement('A'); a.setAttribute('href',window.URl.createObjectURL(filE)); a.setAttribute('download','file-name-of-download.ext'); // in firefox `a.click()` works only if `a` element is in DOM,so... document.documentElement.appendChild(a); a.click(); console.log('done'); });
在Chrome57和FF54中测试过.
以上是大佬教程为你收集整理的jquery – 如何在iframe中加载请求标头之前设置它全部内容,希望文章能够帮你解决jquery – 如何在iframe中加载请求标头之前设置它所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。