iframe无刷新上传,firefox不执行onsubmit

yak 发布于 2016/06/05 10:37
阅读 312
收藏 0
<!DOCTYPE HTML>
<html lang="ru-RU">
<head>
  <title>
 
</title>
  <meta charset="UTF-8">
<style type="text/css">
iframe,input,button,li{
height:30px;
}
 
</style>
</head>
<body>

 
 
 
<div id='attachment' >   </div>
<ul  id="toolsbar">
 <li id="uploadFile">
   <div  >
     <iframe src="upload/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+="<li><b>"+filename+" </b> X</li> "

}

};

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

Uploader.fireUpload();

})


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


upload/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>


upload.php


<?php

print_r($_FILES);



加载中
0
zabcd117
zabcd117
你在上传的时候,直接获取iframe里面的form执行submit,别用button的click试试。
yak
yak
ff不能用form的submit方法,只能click
返回顶部
顶部