我有这样的HTML:iframe加载时,如何让iframe在主页上运行Javascript函数?
<script type="text/javascript">
function uploadDone(response) {
alert(response);
}
function init() {
document.getElementById('file_upload_form').onsubmit=function() {
document.getElementById('file_upload_form').target = 'upload_target'; //'upload_target' is the name of the iframe
document.getElementById("upload_target").onload = uploadDone(response);
}
}
</script>
<form method="get" id="file_upload_form" enctype="multipart/form-data" action="../includes/parsecsv.ajax.php" target="upload_target">
<label class="uploadClick">
<button class="normal">Click to Upload Sign Ups CSV</button>
<input type="file" id="uploadSignups file" name="file">
</label>
<span class="uploadDrag"><span>or</span>Drag Your Sign Ups CSV Here</span>
<button type="submit" name="action">hello</button>
<iframe id="upload_target" name="upload_target" src="" style="width:0px; height:0px; border:none;"></iframe>
</form>
它应该是,当你点击提交按钮,上传文件输入选定的文件ajaxically通过。我似乎已经能够得到它进行上传,但上传完成后似乎没有运行uploadDone()
?任何想法它有什么不对?
表包含ENCTYPE =的multipart/form-data的,但不包含的method = post。通常使用method = GET提交并且不使用enctype。 - 什么时候你的uploadDone()函数触发 – manny