让加载慢的网页内容飞一会再显示

来源:互联网 发布:同方模具 蓝天模具知乎 编辑:程序博客网 时间:2024/06/11 04:21
 

最近在给一个论坛加上了天气预报代码(<iframe src="http://m.weather.com.cn/m/pn7/weather.htm?id=101120901T " width="300" height="20" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" allowtransparency="true" scrolling="no"></iframe>)后, 页面打开明显慢了,本来想放在页面最后显示,可客户不同意,要求必须加在最上面尴尬,只好变通了:

是DISCUZ论坛,其实也可以用在其他加载慢的代码,起到一个延缓加载,把加载慢的放到最后加载,非常有用!

 

<div id="weather">天气预报载入中…(或者其他字都可以,如果是乱码就加 Wait......)</div>

然后在template/wind/footer.htm的</body>代码前加入一下代码

<div id="show_weather"><iframe src="http://m.weather.com.cn/m/pn7/weather.htm?id=101120901T " width="300" height="20" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" allowtransparency="true" scrolling="no"></iframe></div>
<script type="text/javascript">
document.getElementById("weather").innerHTML = document.getElementById("show_weather").innerHTML;
document.getElementById("show_weather").innerHTML = "";
</script>

 

怎么样,有效果吧?吐舌头

原创粉丝点击