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

iframe兑现局部刷新例子

2012-11-10 
iframe实现局部刷新例子?当页面有一部分是不变的或整个页面的图片很多时,使用局部刷新会是不错的选择。否则

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的内容

?

另一种方法:

?

???? <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>

?

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

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

热点排行
Bad Request.