auto refresh iframe
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title> <script></script>
<style>
.gray {color:#ccc !important; background-color:#eee !important; border-color:#eee !important; }
.black { color:black !important; }
#autoRefresh_label { cursor:pointer; }
</style>
</head>
<body>
<div id="autoRefresh_div" style="-moz-user-select:none;" onselectstart="javascript:return false;">
<input type="checkbox" checked="checked" id="autoRefresh_checkbox" />
<label for="autoRefresh_checkbox" id="autoRefresh_label">
每
<select id="autoRefresh_select">
<option value="1">1分钟</option>
<option value="3" selected="selected">3分钟</option>
<option value="10">10分钟</option>
<option value="30">30分钟</option>
</select>
自动更新</label>
</div> <script> window.$$ = function (e) {
if (document.getElementById(e)) { return document.getElementById(e); }
} //父子同域才可以使用
//document.domain = '';如果父子同域后缀,则可以通过设置该属性而实现跨域访问 window.autoRefresh = function () {
this.getCurrentIframe = function () {
if (!parent || parent.document.getElementsByTagName('iframe').length === 0) {
return undefined;
}
var iframes = parent.document.getElementsByTagName('iframe');
for (var i = 0; i < iframes.length; i++) {
if (iframes[i].src === document.location.href) {
return iframes[i];
}
} } var that = this; this.init = function () { if (!parent['autoRefresh_checkbox_checked']) {
parent['autoRefresh_checkbox_checked'] = $$('autoRefresh_checkbox').checked;
}
else {
$$('autoRefresh_checkbox').checked = parent['autoRefresh_checkbox_checked'];
} $$('autoRefresh_checkbox').onchange = function () {
parent['autoRefresh_checkbox_checked'] = $$('autoRefresh_checkbox').checked; };
$$('autoRefresh_checkbox').onclick = function () { $$('autoRefresh_checkbox').checked === false
? $$('autoRefresh_select').className = $$('autoRefresh_label').className = 'gray'
: $$('autoRefresh_select').className = $$('autoRefresh_label').className = 'black';
} if (!parent['autoRefresh_select_selected']) {
parent['autoRefresh_select_selected'] = $$('autoRefresh_select').value;
}
else {
$$('autoRefresh_select').value = parent['autoRefresh_select_selected'];
}
$$('autoRefresh_select').onchange = function () {
parent['autoRefresh_select_selected'] = $$('autoRefresh_select').value;
this.start();
}; } this.start = function () {
var time = parseInt($$('autoRefresh_select').value) * 1000 * 60;
setInterval(function () {
if ($$('autoRefresh_checkbox').checked) {
that.getCurrentIframe().src = document.location.href;
}
}, time);
} this.init();
} new autoRefresh().start(); </script>
</body> </html>
if you put these codes in the iframe,then iframe can refresh auto.
auto refresh iframe的更多相关文章
- acm对拍程序 以及sublime text3的文件自动更新插件auto refresh
acm等算法比赛常用---对拍 以及sublime text3的文件自动更新插件auto refresh 对拍 对拍即程序自动对比正确程序的运行结果和错误程序的运行结果之间的差异 废话少说, 直接上操 ...
- iframe父子页面之间相互调用元素和函数
<!doctype html> <html> <head> <meta http-equiv="Content-Type" content ...
- iframe参数
iframe参数: <iframe src="test.jsp" width="100″ height="50″ frameborder="no ...
- iframe的各项參数
iframe的各项參数: <iframe src="test.jsp" width="100″ height="50″ frameborder=" ...
- Markdown中如何插入视频 > iframe?
关于Markdown中如何插入视频这一问题 网上众说纷纭,一直也没找到一个确切的答案,想来也是,这些东西毕竟还不算成熟.各种以前提供过的方法现在来讲,可能在更新或是关闭大潮中又没了 而且,Ma ...
- iframe标签用法详解
功能:iframe标签用于定义内联框架. 语法:<iframe></iframe> 内联框架是在一个页面中嵌入另一个页面. 有很多网页看上去是一个网页,但实际上它其中可能镶 ...
- vue组件中使用iframe元素
需要在本页面中展示vue组件中的超链接,地址栏不改变的方法: <template> <div class="accept-container"> <d ...
- iframe使用大全
<iframe src=”you page’s url” width=”100″ height=”30″ frameborder=”no” border=”0″ marginwidth=”0″ ...
- Iframe 用法的详细讲解
1转自:https://blog.csdn.net/judyge/article/details/51786064 zIframe 用法的详细讲解 把iframe解释成“浏览器中的浏览器“很是恰当 & ...
随机推荐
- raspberry pi2 智能小车源码及测试视频
作者:XIAOBO QQ:463431476 转载请注明作者Python 源代码 import RPi.GPIO as GPIO #human-computer-interaction import ...
- JavaScript中的函数表达式
在JavaScript中,函数是个非常重要的对象,函数通常有三种表现形式:函数声明,函数表达式和函数构造器创建的函数. 本文中主要看看函数表达式及其相关的知识点. 函数表达式 首先,看看函数表达式的表 ...
- 微信公众平台C# SDK:Senparc.Weixin.MP.dll
https://github.com/Senparc/WeiXinMPSDK [转] http://www.cnblogs.com/szw/archive/2013/01/13/senparc-wei ...
- 关于log4j的讨论
1.LoggersLoggers组件在此系统中被分为五个级别:DEBUG.INFO.WARN.ERROR和FATAL.这五个级别是有顺序的,DEBUG < INFO < WARN < ...
- JMeter学习(一)工具简单介绍
一.JMeter 介绍 Apache JMeter是100%纯JAVA桌面应用程序,被设计为用于测试客户端/服务端结构的软件(例如web应用程序).它可以用来测试静态和动态资源的性能,例如:静态文件, ...
- Quartz集群配置
先看看quartz的持久化基本介绍: 引用 1 大家都清楚quartz最基本的概念就是job,在job内调用具体service完成具体功能,quartz需要把每个job存储起来,方便调度,quartz ...
- QuickFIX/N入门:(三)如何配置QuickFIX/N
Acceptor或者Initiator能够为您维护尽可能多的FIX会话,因而FIX会话标识的唯一性非常重要.在QuickFIX/N中,一个FIX会话的唯一标识是由:BeginString(FIX版本号 ...
- [No000004]在WIN7/8任务栏创建快捷方式
在XP时代,有一个快速启动栏,创建快捷方式只需要把快捷方式放在“%AppData%\Roaming\Microsoft\Internet Explorer\Quick Launch”文件夹下即可,如果 ...
- Fragment的startActivityForResult详细解决方案
由于要用到Fragment中startActivityForResult,所以一开始就直接用activity.startActivityForResult(intent, 0);发现这样用首先会跳转到 ...
- C# 内存信息
Process proc = Process.GetCurrentProcess(); Console.Write("专用工作集内存:"); ...