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解释成“浏览器中的浏览器“很是恰当 & ...
随机推荐
- java 自动装箱自动拆箱
1.Java数据类型 在介绍Java的自动装箱和拆箱之前,我们先来了解一下Java的基本数据类型. 在Java中,数据类型可以分为两大种,Primitive Type(基本类型)和Reference ...
- 动手学习TCP:总结和索引
TCP是一个十分复杂的协议,通过前面几篇文章只涉及了TCP协议中一些基本的概念. 虽然说都是一些TCP最基本的概念,但是试验过程中一直在踩坑,例如:TCP flag设置错误,seq.ack号没有计算正 ...
- windows 7 语言切换 Vistalizator
Try Vistalizator - this tool allows you to change display language in Windows editions other than (o ...
- UVA 11582 Colossal Fibonacci Numbers!【数学】
大一刚开始接触ACM就买了<算法竞赛入门经典>这本书,当时只能看懂前几章,而且题目也没做,粗鄙地以为这本书不适合自己.等到现在快大三了再回过头来看,发现刘老师还是很棒的! 扯远了... 题 ...
- 另类Unity热更新大法:代码注入式补丁热更新
对老项目进行热更新 项目用纯C#开发的? 眼看Unity引擎热火朝天,无数程序猿加入到了Unity开发的大本营. 一些老项目,在当时ulua/slua还不如今天那样的成熟,因此他们选择了全c#开发:也 ...
- 多年前写的一个ASP.NET网站管理系统,到现在有些公司在用
多年前写的一个ASP.NET网站管理系统,到现在有些公司在用 今早上接到一个电话,自已多年前写的一个ASP.NET网站管理系统,一个公司在用,出了点问题, 第一点是惊奇,5,6年前的东东,手机号码换了 ...
- HTML:图片热点 网页划区 表单
图片热点: 划出图片中的区域,做超链接,点击该区域就可以直接跳转到链接网站 <img src="../../../3.jpg" title="血精灵" u ...
- windows下 git配置ssh
1. 打开 git bash 2. cd ~/.ssh 3. ssh-genkey (一致next), 会生成 id_rsa (密钥); id_rsa.pub(公钥) 4. 用记事本打开 id_rs ...
- ASP.NET CORE 1.0 MVC API 文档用 SWASHBUCKLE SWAGGER实现
from:https://damienbod.com/2015/12/13/asp-net-5-mvc-6-api-documentation-using-swagger/ 代码生成工具: https ...
- linux运维中的命令梳理(四)
----------管理命令---------- ps命令:查看进程 要对系统中进程进行监测控制,查看状态,内存,CPU的使用情况,使用命令:/bin/ps (1) ps :是显示瞬间进程的状态,并不 ...