首页 技术 正文
技术 2022年11月14日
0 收藏 822 点赞 4,974 浏览 820 个字

需求描述:

当页面有一部分是不变的或整个页面的图片很多时,可以考虑使用局部刷新,以提高整体的下载速度与用户体验。

 

1,iframe实现局部刷新的方法一

复制代码代码示例:<script type="text/javascript">

    $(function(){

    $("#a1").click(function(){

     var name= $(this).attr("name");

     $("#iframe").attr("src",name).ready();

    })

    $("#a2").click(function(){

     var name= $(this).attr("name");

     $("#iframe").attr("src",name).ready();

    })

})

</script>

<a href="#" id="a1" name="a1.html">1</a>

<a href="#" id="a2" name="a2.html">2</a>

<iframe src="" id="iframe"></iframe>

 

当点a1时在iframe里显示a1.html的内容,点a2时在iframe里显示a2.html的内容。

 

2,iframe实现局部刷新的方法二

复制代码代码示例:<a href="a1.html" id="a1" name="a1.html" target="i">1</a>

<a href="a2.html" id="a2" name="a2.html" target="i">2</a>

<iframe src="" id="iframe" name="i"></iframe>

 

备注:

<from> 同样也有target属性,作用和<a>一样

这个方式如果<from>或<a>提交到某个Action中再跳转到a1.html中效果一样,如果在Action中有req.set或session.set,最后在iframe中同样可以显示出来。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,494
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295