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解释成“浏览器中的浏览器“很是恰当 & ...
随机推荐
- Windows 10 Threshold 2 升级记录
昨天(11月17日)升级到Windows 10 Threshold 2版本.我的使用的设备是Surface Pro 3,4G内存,128G硬盘. Threshold 2是作为一个Windows系统更新 ...
- AI (Adobe Illustrator)详细用法(三)
本文主要是介绍和色彩相关的用法. 一.路径外观设置 1.设置描边粗细 手动输入20px 下拉选择 鼠标选中数值,按向上或向下的箭头调整 在右边的描边菜单中修改 Note:按住shift键,然后上下箭头 ...
- c++关于析构的那点小事(个人吐槽向
#include<iostream> using namespace std; class test { int *i; public: test(int n) { i = new int ...
- windows 10 & Office 2016 安装
Office 2016 VOL版 http://blog.sina.com.cn/s/blog_470614a90102vtmc.html 专业版合集: magnet:?xt=urn:btih: ...
- android camera setMeteringArea详解
摘要: 本文为作者原创,未经允许不得转载:原文由作者发表在博客园:http://www.cnblogs.com/panxiaochun/p/5802814.html setMeteringArea() ...
- 使用 React.js 的渐进式 Web 应用程序:第 1 部分 - 介绍
使用 React.js 的渐进式 Web 应用程序:第 1 部分 - 介绍 使用 React.js 的渐进式 Web 应用程序:第 1 部分 - 介绍 来自译者 markzhai:大家也知道最近 ...
- 转:大气炫酷焦点轮播图js特效
使用方法 Step 1. 在html的标签内引入相关文件 <script type="text/javascript" src="js/myfocus-2.0.0. ...
- XSS安全性过滤
XSS攻击很多发生在用户在可以输入的地方输入了不友好的内容,根本处理方法是在输入内容中进行过滤 PHP或者java,基本都有现成的jar包或者php框架,调用自动过滤用户的输入内容,避免了XSS 防御 ...
- guava常用操作
Jack47 我思故我在 Google Java编程库Guava介绍 本系列想介绍下Java下开源的优秀编程库--Guava[ˈgwɑːvə].它包含了Google在Java项目中使用一些核心库,包含 ...
- 链剖&LCT总结
在搞LCT之前,我们不妨再看看喜闻乐见的树链剖分. 树链剖分有一道喜闻乐见的例题:NOI2015 软件包管理器 如果你看懂题目了,你就会明白它是叫你维护一个树,这棵树是不会动的,要兹磁子树求和,子树修 ...