JS实现刷新iframe的方法

摘要:
现在,当内容被添加并且记录被添加到链接列表时,您需要刷新列表iframe。使用parent.location。在内容iframe Reload()的提交js中,刷新所有父页面。因为另一个iframe没有默认url,只能从列表中选择,所以只显示列表iframe的内容。document.frames.location。重新加载;//okdocument.frames.document.location。重新加载;//okdocument.frames.document.location=“/public/alarmsum.asp”;//okdocument。getElementByIdx_x.src=“http://t.zoukankan.com/public/alarmsum.asp“mce_src=”/public/alarmsum.asp“;//okdocument.frames.src=”http://t.zoukankan.com/public/alarmsum.asp“Mce_src=”/public/larmsum。asp“;//没有任何变化。请注意区别。Document.all.refreshAlarm或Document.frames在information.asp页面中获取iframe标记,因此它对src属性操作非常有用。Document.frames.Document获取iframe中的内容,即“/public/larmsum”中的内容。asp”。

<iframe src="http://t.zoukankan.com/1.htm" name="ifrmname" id="ifrmid"></iframe>

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

<input type="button" name="Button" value="Button"
onclick="document.frames('ifrmname').location.reload()">

  或

<input type="button" name="Button" value="Button"
onclick="document.all.ifrmname.document.location.reload()">

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

<input type="button" name="Button" value="Button"
onclick="ifrmid.window.location.reload()">

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

<input type="button" name="Button" value="Button"
onclick="window.open(document.all.ifrmname.src,'ifrmname','')">

 

 

 

代码如下:<input type=button value=刷新 onclick="history.go(0)">

代码如下:<input type=button value=刷新 onclick="location.reload()">

代码如下:<input type=button value=刷新 onclick="location=location">

代码如下:<input type=button value=刷新 onclick="window.navigate(location)">

代码如下:<input type=button value=刷新 onclick="location.replace(location)">

下面这三种我就不知道该怎么用了,就把代码放在下面吧,哪位要是会的话,可教教大家。

<input type=button value=刷新 onclick="document.execCommand(@#Refresh@#)">

<input type=button value=刷新 onclick="window.open(@#自身的文件@#,@#_self@#)">

<input type=button value=刷新 onClick=document.all.WebBrowser.ExecWB(22,1)>

 

 

 


父页面中存在两个iframe,一个iframe中是一个链接列表,其中的链接指向另一个iframe,用于显示内容。现在当内容内容添加后,在链接列表中添加了一条记录,则需要刷新列表iframe。

在内容iframe的提交js中使用parent.location.reload()将父页面全部刷新,因为另一个iframe没有默认的url,只能通过列表选择,所以只显示了列表iframe的内容。

使用window.parent.frames["列表iframe名字"].location="列表url"即可进刷新列表iframe,而内容iframe在提交后自己的刷新将不受影响。

 

 

 

 

 

 

document.frames("refreshAlarm").location.reload(true); //ok

document.frames("refreshAlarm").document.location.reload(true); //ok

document.frames("refreshAlarm").document.location="/public/alarmsum.asp";//ok

document.getElementByIdx_x("refreshAlarm").src="http://t.zoukankan.com/public/alarmsum.asp" mce_src="/public/alarmsum.asp"; //ok

document.frames("refreshAlarm").src="http://t.zoukankan.com/public/alarmsum.asp" mce_src="/public/alarmsum.asp"; //没变化,没动静

注意区别,document.all.refreshAlarm 或 document.frames("refreshAlarm") 得到的是information.asp页面中那个iframe标签,所以对src属性操作有用。
document.frames("refreshAlarm").document得到iframe里面的内容,也就是"/public/alarmsum.asp"中的内容。

这里需要补充说明的是:

采用document.getElementByIdx_x获取后reload是不可以的

但是可以这样

var myiframe = document.getElementByIdx_x("iframe1");

myiframe.src = myiframe.src; //这样同样可以起到刷新的效果。


自动刷新页面


javascript(js)自动刷新页面的实现方法总结2008-04-18 13:24
自动刷新页面的实现方法总结:

1)
<meta http-equiv="refresh"content="10;url=跳转的页面">
10表示间隔10秒刷新一次
2)
<script language=''javascript''>
window.location.reload(true);
</script>
如果是你要刷新某一个iframe就把window给换成frame的名字或ID号
3)
<script language=''javascript''>
window.navigate("本页面url");
</script>
4>

function abc()
{
window.location.href="http://t.zoukankan.com/blog/window.location.href";
setTimeout("abc()",10000);
}

刷新本页:
Response.Write("<script language=javascript>window.location.href=window.location.href;</script>")

刷新父页:
Response.Write("<script language=javascript>opener.location.href=opener.location.href;</script>")

转到指定页:
Response.Write("<script language=javascript>window.location.href='http://t.zoukankan.com/yourpage.aspx';</script>")


刷新页面实现方式总结(HTML,ASP,JS)
'by aloxy

定时刷新:
1,<script>setTimeout("location.href='http://t.zoukankan.com/url'",2000)</script>

说明:url是要刷新的页面URL地址
2000是等待时间=2秒,

2,<meta name="Refresh" content="n;url">

说明:
n is the number of seconds to wait before loading the specified URL.
url is an absolute URL to be loaded.
n,是等待的时间,以秒为单位
url是要刷新的页面URL地址

3,<%response.redirect url%>

说明:一般用一个url参数或者表单传值判断是否发生某个操作,然后利用response.redirect 刷新。

4,刷新框架页
   〈script language=javascript>top.leftFrm.location.reload();parent.frmTop.location.reload();</script〉

弹出窗体后再刷新的问题


Response.Write("<script>window.showModalDialog('../OA/SPCL.aspx',window,'dialogHeight: 300px; dialogWidth: 427px; dialogTop: 200px; dialogLeft: 133px')</script>");//open
             Response.Write("<script>document.location=document.location;</script>");

在子窗体页面代码head中加入<base target="_self"/>

刷新的内容加在    if (!IsPostBack) 中

在框架页中右面刷新左面
    //刷新框架页左半部分
    Response.Write("<script language=javascript>");
    Response.Write("parent.left.location.href='http://t.zoukankan.com/PayDetailManage_Left.aspx'");
    Response.Write("</script>");


页面定时刷新功能实现

有三种方法:
1,在html中设置:
<title>xxxxx</title>之後加入下面这一行即可!
定时刷新:<META HTTP-EQUIV="Refresh" content="10">
10代表刷新间隔,单位为秒

2.jsp
<% response.setHeader("refresh","1"); %>
每一秒刷新一次

3.使用javascript:
<script language="javascript">
setTimeout("self.location.reload();",1000);
<script>
一秒一次


页面自动跳转:
1,在html中设置:
<title>xxxxx</title>之後加入下面这一行即可!
定时跳转并刷新:<meta http-equiv="refresh" content="20;url=http://自己的URL">,
其中20指隔20秒后跳转到http://自己的URL 页面。


点击按钮提交表单后刷新上级窗口

A窗口打开B窗口

然后在B里面提交数据至C窗口

最后要刷新A窗口

并且关闭B窗口

几个javascript函数

//第一个自动关闭窗口
<script language="javascript">
<!--
function clock(){i=i-1
document.title="本窗口将在"+i+"秒后自动关闭!";
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=2
clock();
//-->
</script>

//第二个刷新父页面的函数

<script language="javascript">
opener.location.reload();
</script>


//第三个打开窗口

<script language="javascript">
function show(mylink,mytitle,width,height)
{mailwin=window.open(mylink,mytitle,'top=350,left=460,width='+width+',height='+height+',scrollbars=no')}
</script>

免责声明:文章转载自《JS实现刷新iframe的方法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇用Visual Studio 2015 编写 MASM 汇编程序(一)环境配置Java高性能并发编程——线程池下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

pyautogui自动化控制鼠标和键盘操作

pyautogui自动化控制鼠标和键盘操作 安装 pyautogui鼠标操作样例 pyautogui键盘操作样例 按键支持 提示信息 alert option password prompt 截屏 整个屏幕截图并保存 屏幕查找图片位置并获取中间点 安全设置 PyAutoGUI是一个纯Python的GUI自动化工具,其目的是可以用程序自动控...

iframe标签

今天向大家介绍一个标签的使用,Iframe标签,该标签可以被称之为伪Ajax,在ajax还没怎么盛行之时,大家为了提高客户端的用户体验,实现页面的局部刷新就是使用frame标签的,确实,上次我使用该标签也是看中了它的局部刷新: 使用的效果图: 如上图所示左边是导航栏,右边是点击导航后显示的页面,实现的功能就是点击左边的导航栏,不进行页面的整体刷新,而是直...

生产环境服务器安全策略与系统性能优化评估

生产环境服务器安全策略与系统性能优化评估 1. Linux的运维经验分享与故障排查思路 1.1 线上服务器安装基本策略和经验 精简安装策略: 仅安装需要的,按需安装,不用不装 开发包,基本网络包,基本应用包 1.1.1 CentOS-6.x 1.1.2 CentOS-7.x 盘系统-默认按照分区方式数据盘单独挂载 1.2 线上服务器网络设置经...

细说 Form (表单)

细说 Form (表单) 阅读目录 开始 简单的表单,简单的处理方式 表单提交,成功控件 多提交按钮的表单 上传文件的表单 MVC Controller中多个自定义类型的传入参数 F5刷新问题并不是WebForms的错 以Ajax方式提交整个表单 以Ajax方式提交部分表单 使用JQuery,就不要再拼URL了! id, name 有什么关系 使用C#...

JS实现div的抖动:缓动式抖动

代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Title</title> <style> #di...

layui弹出层之应用实例讲解

从酒店管理系统到智能门锁及其现在的资源共享平台,layui框架,我们团队用的比较多的就是这个layui弹出层。 layui弹出层,除了页面iframe层我们比较常用还有就是表单校验和其他相关的友好提示信息。 通常比较常用的方式是layui+jQuery,layui主要引用layui相关的js和css文件,jQuery的话,通常就是两个版本,压缩版和源码版,...