首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JS上载附件有关问题

2012-09-04 
JS下载附件问题parent.htmlscript languagejavascript!--functio

JS下载附件问题
parent.html
=================================
<script language="javascript"> 
<!-- 
function openChild(){ 
 var k = window.showModalDialog("child.html",window,"dialogWidth:335px;status:no;dialogHeight:300px;");

</script> 
<input type ="button" value="转到子页面" onClick="openChild();">
=================================
child.html
=================================
<script language="javascript">
function downloadFile() {  
 
  url = "xxxx.rar";
  var elemIF = document.createElement("iframe");  
  elemIF.src = url;  
  elemIF.style.display = "none";  
  document.body.appendChild(elemIF);  
}
</script> 
<div class="login_center">
  <input type="button" onClick="downloadFile('')" value="点击">
</div>
现在单击onclick事件能下载附件。
但是需要的是页面一载入就想调用downloadFile()方法。
然后这样写 <body onLoad="downloadFile('')"></body>
就发现IE不弹下载附件,如何解决?

[解决办法]
这个是为了安全性考虑这样设计的
js无法实现,可以用服务器代码实现,想直接弹出下载只能在后台往前台写文件
网上搜一搜吧,很多,就是用Response.Write实现这个功能

热点排行