首页 > firefox用iframe无刷新上传不执行frame页面的onsubmit

firefox用iframe无刷新上传不执行frame页面的onsubmit

上传用的iframe页面
frame.html

<html><head><script type="text/javascript">


function fileChange(input){
 
        parent.Uploader.startUpload(input.files[0].name);
     
}
function CheckUpload(){
 
alert('CheckUpload reutrn true;');
 
    return true;
 
    
}
function checkSubmit(){
    alert('checkSubmit return true');
    return true;
}
</script>

</head>
<body>

<form action="upload.php" method="post"  onsubmit="return  checkSubmit();"  
enctype="multipart/form-data">
 
<input type="file" name="file" id="file"  onchange="fileChange(this);" /> 
<br />
<input type="submit" name="submit" id="Button1" value="Submit"  onclick= "return CheckUpload();" />
</form>

</body>
</html>

主页面

<!DOCTYPE HTML><html ><head>  
<meta charset="UTF-8">
<style type="text/css">
iframe,input,button,li{
height:35px;
}
 
</style>
</head>
<body>
<div id='attachment' ></div>
<ul  id="toolsbar">
 <li id="uploadFile">
  <div  >
      <iframe src="frame.html" frameborder="1"  id="uploadfileFrame"   scrolling="no"></iframe>
   </div>
 </li>
</ul>
<hr>
<input  id='msg' />
<button id='send' > SEND </button>




<script type="text/javascript">

function $(id){

    return document.getElementById(id);

}

var Uploader={
    hasFileReady:false,
    uploadMsg:'',
    filename:'xx.jpg',


    fireUpload: function(event) {
        
            var fileframe = $("uploadfileFrame").contentWindow.document.getElementById("Button1");

             fileframe.click();
      
    
    },


    startUpload: function(filename) {
       
 
          $("toolsbar").style.display = "none";

          $("attachment").innerHTML+="<h1>"+filename+"</h1> X"

}

};

document.getElementById('send').addEventListener('click',function(){

    Uploader.fireUpload();

})


</script>
</body>
</html>

upload.php

<?php
print_r($_FILES);

在主页面的 fireUpload 中

$("uploadfileFrame").contentWindow.document.forms[0].submit(); 

直接提交也没反应

【热门文章】
【热门文章】