<!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的更多相关文章

  1. acm对拍程序 以及sublime text3的文件自动更新插件auto refresh

    acm等算法比赛常用---对拍 以及sublime text3的文件自动更新插件auto refresh 对拍 对拍即程序自动对比正确程序的运行结果和错误程序的运行结果之间的差异 废话少说, 直接上操 ...

  2. iframe父子页面之间相互调用元素和函数

    <!doctype html> <html> <head> <meta http-equiv="Content-Type" content ...

  3. iframe参数

    iframe参数: <iframe src="test.jsp" width="100″ height="50″ frameborder="no ...

  4. iframe的各项參数

    iframe的各项參数: <iframe src="test.jsp" width="100″ height="50″ frameborder=" ...

  5. Markdown中如何插入视频 > iframe?

    关于Markdown中如何插入视频这一问题   网上众说纷纭,一直也没找到一个确切的答案,想来也是,这些东西毕竟还不算成熟.各种以前提供过的方法现在来讲,可能在更新或是关闭大潮中又没了   而且,Ma ...

  6. iframe标签用法详解

      功能:iframe标签用于定义内联框架. 语法:<iframe></iframe> 内联框架是在一个页面中嵌入另一个页面. 有很多网页看上去是一个网页,但实际上它其中可能镶 ...

  7. vue组件中使用iframe元素

    需要在本页面中展示vue组件中的超链接,地址栏不改变的方法: <template> <div class="accept-container"> <d ...

  8. iframe使用大全

    <iframe src=”you page’s url” width=”100″ height=”30″ frameborder=”no” border=”0″ marginwidth=”0″ ...

  9. Iframe 用法的详细讲解

    1转自:https://blog.csdn.net/judyge/article/details/51786064 zIframe 用法的详细讲解 把iframe解释成“浏览器中的浏览器“很是恰当 & ...

随机推荐

  1. KVM 介绍(2):CPU 和内存虚拟化

    学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...

  2. 玩转Windows Azure存储服务——网盘

    存储服务是除了计算服务之外最重要的云服务之一.说到云存储,大家可以想到很多产品,例如:AWS S3,Google Drive,百度云盘...而在Windows Azure中,存储服务却是在默默无闻的工 ...

  3. plain framework 1 参考手册 入门指引之 代码风格

    代码风格 介绍 介绍 框架自身采用了google的C++风格,作者也鼓励在你的应用中使用此风格,有关此风格你可以查阅相关资料了解.下面是一段plain framework中的代码,以便大家参考: 你可 ...

  4. NOIP2015子串[序列DP]

    题目背景 无 题目描述 有两个仅包含小写英文字母的字符串 A 和 B.现在要从字符串 A 中取出 k 个互不重 叠的非空子串,然后把这 k 个子串按照其在字符串 A 中出现的顺序依次连接起来得到一 个 ...

  5. ubuntu14安装Qt

    首先下载Qt源码 https://download.qt.io/archive/qt/4.8/4.8.4/ 这里我下载的是qt-everywhere-opensource-src-4.8.4.tar. ...

  6. 开发之UI篇

    首先这里介绍一个软件一个插件,它们的主要功能是方便开发者看UI(如尺寸,颜色,大小等),两个配合使用 一. Sketch软件 1.Sketch  看ui图,还可以切图 2.Sketch 如何切图: 1 ...

  7. Meet Python: little notes

    Source: http://www.liaoxuefeng.com/ ❤ Escape character: '\' - '\n': newline; - '\t': tab; - '\\': \; ...

  8. ListView实现原理

    转载:http://blog.csdn.net/guolin_blog/article/details/44996879 在Android所有常用的原生控件当中,用法最复杂的应该就是ListView了 ...

  9. 软件工程(DBSD2016) Git Review

    说明:任何问题请在评论区说明,会集中更新回复. 连连看组 源码: git clone https://git.coding.net/jx8zjs/llk.git 提交日志 一共有20次commit日志 ...

  10. swift——uiwebview的使用

    首先,创建一个label: agreeDeal = UILabel() let tap = UITapGestureRecognizer.init(target: self, action: #sel ...