获取错误在IE中拒绝WebPage访问 [英] Get Error WebPage Access is denied in IE

查看:143
本文介绍了获取错误在IE中拒绝WebPage访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用$('#dropbox')打开文件对话框,点击
然后选择要上传的文件。然后单击Firefox成功文件上传中的按钮上传文件,但是在IE获取错误WebPage访问被拒绝( line form.submit(); ))。


$ b $

  $(document).ready(function(){
if((support.fileReader == false)& &(support.formData == false)){
$('input [type = button]')。eq(0).attr(onClick,'fileUpload(this.form,UploadHandler。 ); $ b $('input [type = file]')。eq(0).attr(onchange,fileSelectedIE();); $ b ();
$ b $('#dropbox')。click(function(){
$('input [type = file]')。click();
});
});
functionfileUpload(form,action_url,div_id){
// Createtheiframe ...
variframe = document.createElement(iframe);
iframe.setAttribute(id,upload_iframe);
iframe.setAttribute(name,upload_iframe);
iframe.setAttribute(width,0);
iframe.setAttribute(height,0);
iframe.setAttribute(border,0);
iframe.setAttribute(style,width:0; height:0; border:none;);
// target =#fileIframe
// Addtodocument ...
form.parentNode.appendChild(iframe);
window.frames ['upload_iframe']。name =upload_iframe;

iframeId = document.getElementById(upload_iframe);

// Addevent ...
vareventHandler = function(){
$ b $ if(iframeId.detachEvent){
iframeId.detachEvent(onload ,事件处理程序);
$('#progressNumber')。text(100%);
}
elseiframeId.removeEventListener(load,eventHandler,false);
if(iframeId.addEventListener)iframeId.removeEventListener(progress,uploadProgress1,false);
// Messagefromserver ...
if(iframeId.contentDocument){
content = iframeId.contentDocument.body.innerHTML;
} elseif(iframeId.contentWindow){
content = iframeId.contentWindow.document.body.innerHTML;
} elseif(iframeId.document){
content = iframeId.document.body.innerHTML;
}

document.getElementById(div_id).innerHTML = content;

// Deltheiframe ...
setTimeout('iframeId.parentNode.removeChild(iframeId)',250);
}

if(iframeId.addEventListener){
iframeId.addEventListener(load,eventHandler,true);
$('#progressNumber')。text(Processing ...);

if(iframeId.attachEvent)iframeId.attachEvent(onload,eventHandler);
//if(iframeId.addEventListener)iframeId.addEventListener(\"progress\",uploadProgress1,false);

// SetPropertiesofform ...
form.setAttribute(target,upload_iframe);
form.setAttribute(action,action_url);
form.setAttribute(method,post);
form.setAttribute(enctype,multipart / form-data);
form.setAttribute(encoding,multipart / form-data);
// Submittheform ...
** form.submit(); **

document.getElementById(div_id).innerHTML =正在上传...;

functionfileSelectedIE(){
varfullname = $('#fileToUpload')。val()。toString();
varIndexExt = fullname.lastIndexOf(。);
varext = fullname.substr(IndexExt + 1).toString();
varIndexFileName = fullname.lastIndexOf(\\);
varFileName = fullname.substring(IndexFileName + 1,IndexExt).toString();
document.getElementById('fileName')。innerHTML ='Name:'+ FileName;
document.getElementById('fileSize')。innerHTML ='Size:NotSupport';
document.getElementById('fileType')。innerHTML ='Type:'+ ext;
}

< div id =dropbox>< / div>
< input type =filename =fileToUpload []id =fileToUpload/>< / br>
< input type =buttonvalue =upload/>

在IE中需要什么?


I'm open file dialog with $('#dropbox').click And then pick a file to upload . And then click button upload file in Firefox success file upload but in IE Get Error WebPage Access is denied(line form.submit();).

$(document).ready(function(){
if((support.fileReader==false)&&(support.formData==false)){
$('input[type=button]').eq(0).attr("onClick",'fileUpload(this.form,"UploadHandler.ashx","upload");returnfalse;');
$('input[type=file]').eq(0).attr("onchange","fileSelectedIE();");
}
$('#dropbox').click(function(){
$('input[type=file]').click();
});
});
functionfileUpload(form,action_url,div_id){
//Createtheiframe...
variframe=document.createElement("iframe");
iframe.setAttribute("id","upload_iframe");
iframe.setAttribute("name","upload_iframe");
iframe.setAttribute("width","0");
iframe.setAttribute("height","0");
iframe.setAttribute("border","0");
iframe.setAttribute("style","width:0;height:0;border:none;");
//target="#fileIframe"
//Addtodocument...
form.parentNode.appendChild(iframe);
window.frames['upload_iframe'].name="upload_iframe";

iframeId=document.getElementById("upload_iframe");

//Addevent...
vareventHandler=function(){

if(iframeId.detachEvent){
iframeId.detachEvent("onload",eventHandler);
$('#progressNumber').text("100%");
}
elseiframeId.removeEventListener("load",eventHandler,false);
if(iframeId.addEventListener)iframeId.removeEventListener("progress",uploadProgress1,false);
//Messagefromserver...
if(iframeId.contentDocument){
content=iframeId.contentDocument.body.innerHTML;
}elseif(iframeId.contentWindow){
content=iframeId.contentWindow.document.body.innerHTML;
}elseif(iframeId.document){
content=iframeId.document.body.innerHTML;
}

document.getElementById(div_id).innerHTML=content;

//Deltheiframe...
setTimeout('iframeId.parentNode.removeChild(iframeId)',250);
}

if(iframeId.addEventListener){
iframeId.addEventListener("load",eventHandler,true);
$('#progressNumber').text("Processing...");
}
if(iframeId.attachEvent)iframeId.attachEvent("onload",eventHandler);
//if(iframeId.addEventListener)iframeId.addEventListener("progress",uploadProgress1,false);

//Setpropertiesofform...
form.setAttribute("target","upload_iframe");
form.setAttribute("action",action_url);
form.setAttribute("method","post");
form.setAttribute("enctype","multipart/form-data");
form.setAttribute("encoding","multipart/form-data");
//Submittheform...
**form.submit();**

document.getElementById(div_id).innerHTML="Uploading...";
}
functionfileSelectedIE(){
varfullname=$('#fileToUpload').val().toString();
varIndexExt=fullname.lastIndexOf(".");
varext=fullname.substr(IndexExt+1).toString();
varIndexFileName=fullname.lastIndexOf("\\");
varFileName=fullname.substring(IndexFileName+1,IndexExt).toString();
document.getElementById('fileName').innerHTML='Name:'+FileName;
document.getElementById('fileSize').innerHTML='Size:NotSupport';
document.getElementById('fileType').innerHTML='Type:'+ext;
}

<div id="dropbox"></div>
<input type="file" name="fileToUpload[]" id="fileToUpload" /></br>
<input type="button" value="upload"/>

What do I need in IE?

解决方案

You cannot pragmatically (via Javascript) click a file input element and then submit the associated form via Javascript. IE will simply not allow this. Your workflow is considered to be a security violation. You will need to re-think your approach.

这篇关于获取错误在IE中拒绝WebPage访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆