js下载文件防止白屏

欢迎捐赠

 

思路:用js创建一个iframe,让后指定src为下载目录。
var ifup = document.getElementById("ifup");
if(ifup)
{
document.body.removeChild(ifup);
}
var elemIF = document.createElement("iframe");
elemIF.id='ifup';
elemIF.src = tpri_dmp.root + '/process/Common_File?action=Common_Download&attachid=' + attachid + '&qt=1';
elemIF.style.display = "none";
document.body.appendChild(elemIF);
————————————————
版权声明:本文为CSDN博主「ashou706」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ashou706/article/details/82760477

 

============================================================================================================

Frame/IFrame onload 事件

Frame/IFrame 对象参考手册 Frame/IFrame 对象


定义和用法

onload 事件在frame或者iframe载入完成后被触发。

语法

onload="JavaScriptCode"

 

参数描述
JavaScriptCode 必须。在事件触发后执行的Javascript代码。

 


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 onload 事件


实例

实例 1

在frame载入完成后立即弹出 "Frame is loaded":

<html>
<head>
<script>
function load()
{
alert("Frame is loaded");
}
</script>
</head>

<frameset cols="50%,50%">
  <frame src="frame_a.htm" onload="load()">
  <frame src="frame_b.htm">
</frameset>

</html>

尝试一下 »

 

实例 2

在iframe载入完成后立即弹出 "Iframe is loaded" :

<html>
<head>
<script>
function load()
{
alert("Iframe is loaded");
}
</script>
</head>

<iframe onload="load()" src="http://w3cschool.cc">
<p>Your browser does not support iframes.</p>
</iframe>

</html>

 

posted on 2020-02-18 16:03  漫思  阅读(515)  评论(0编辑  收藏  举报

导航