Home  >  Article  >  Web Front-end  >  JavaScript中iframe实现局部刷新的几种方法汇总_javascript技巧

JavaScript中iframe实现局部刷新的几种方法汇总_javascript技巧

WBOY
WBOYOriginal
2016-05-16 15:21:331497browse

Iframe是一种嵌入网页的框架形式,Web页面可以通过更改嵌入的部分,达到部分内容刷新。

Iframe的用法与普通的标签元素DIV类似,可以指定在页面中嵌入的位置、颜色、界面布局等

一、iframe实现局部刷新方法一


1
2
 

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

二、iframe实现局部刷新的方法二

1
2
 

备注:

同样也有target属性,作用和一样 这个方式如果提交到某个Action中再跳转到a1.html中效果一样,如果在Action中有req.set或session.set,最后在iframe中同样可以显示出来。

三:iframe实现局部刷新的方法三:

方案一:用iframe的name属性定位

方案二:用iframe的id属性定位

方案三:当iframe的src为其它网站地址(跨域操作时)

方案四:通过和替换iframe的src来实现局部刷新

可以用document.getElementById("iframname").src=""来进行iframe得重定向;

示例代码如下:test.html

以上内容给大家介绍了JavaScript中iframe实现局部刷新的几种方法汇总,希望大家根据自己的需求选择适合自己的,有任何问题欢迎给我留言,谢谢!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn