document.referrer的使用和window.opener 跟 window.parent 的区别
偶尔看到了document.referrer,之前一直有点疑惑与window.opener 和 window.parent之间的区别
首先查了一下w3cSCHOOL,
上面的解释:referrer 属性可返回载入当前文档的文档的 URL。
但是解释中没有写怎么载入才能用referrer,
翻看了几篇文章,终于搞懂了。
window.opener是当前页面A通过open方法弹出一个窗口B,那在B页面上 window.opener就是A
window.parent是当前页面C通过location.href转到新的页面D,那在D页面上window.parent就是B 或者是页面E里套一个frame为F,那F页面的window.parent就是E
referrer 描述: document对象的referrer属性,返回导航到当前网页的超链接所在网页的URL。
document.referrer的具体应用场景
如果要显示某一个网站的超链接跳转到你的网站你可以如下:
<script type="text/javascript">
var refurl=document.referrer;
if(refurl.indexOf("wowgame")>-1){
alert("你的来源网址为:【"+document.referrer+"】目前本站与该站已终止合作。");
location.replace(refurl);
}
</script>
js操作frame详细解说,window.opener和window.parent的区别
frame框架里的页面要改其他同框架下的页面或父框架的页面就用parent
window.opener引用的是window.open打开的页面的父页面。
window.frames对象可以引用iframe里的页面,也可以引用frameset里的页面.
可以这样
window.frames[0].document.getElementById('xx');
可以这样
window.frames[0].document.body.innerHTML;
frm = window.parent.window.frames['uploadFrame'];
frmDocument = frm.document;
frm.sb(3); //sb 是uploadFrame页面里的一个函数
对于firefox
如果你遇到报错:parent.document.frames has no properties
换为如下代码就可以了,这个代码IE,ff兼容. frm = window.parent.window.frames['uploadFrame'];其实 frames 集合并不是挂在 document 而是挂在 window 对象下.
注意这样修改frame里的页面有限制,就是必须是同域下的,否则无法访问
如果是同一域下,但是子域名不同,那么涉及到的js,html文件都加上一句。
document.domain = xxx.com [这里填写你的域名]
document.getElementById('iframeid').contentWindow.document.getElementById('someelementid');
document.referrer的使用和window.opener 跟 window.parent 的区别的更多相关文章
- window.opener和window.open的使用
window.opener和window.open的使用 window.opener是指调用window.open方法的窗口.window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击 ...
- window.parent与window.opener、window.showModalDialog的区别 opener和showModalDialog刷新父页面的方法
项目中使用案例: 父窗体 <s:form namespace="/forexagent" id="listSearchForm" name="t ...
- window.opener和window.open
window.open (URL,name,specs,replace)方法用于打开一个新的浏览器窗口或查找一个已命名的窗口. URL:可选.打开指定的页面的URL.如果没有指定URL,打开一个新的空 ...
- js jquery 关闭弹出页面 并刷新父页面(window.opener)
function Closepage() { if (window.opener && !window.opener.closed) { window.parent.opener.lo ...
- window.parent 与 window.opener
window.parent针对iframe,window.opener针对window.open 父页面parent.jsp: <%@ page language="java" ...
- [转]window.opener用法
window.opener 实际上就是通过window.open打开的窗体的父窗体. 比如在父窗体parentForm里面 通过 window.open("subForm.html" ...
- window.opener调用父窗体方法的用法
应用实例: function BindWindowCloss() { $(window).bind('beforeunload', function () { ...
- window.opener用法
[转]window.opener用法 window.opener 实际上就是通过window.open打开的窗体的父窗体. 比如在父窗体parentForm里面 通过 window.open(&quo ...
- window.parent与window.opener的区别
有这样一个需求,弹出一个新窗口 并从该新页面的select选择框中选择需要的类别,再返回到之前的父窗口页面的某个文本框中.这里就要用到window.parent和window.opener 如题两种方 ...
随机推荐
- linux fdisk分区工具
fdisk来自IBM老牌分区工具,支持绝大多数操作系统,几乎所有的linux的发行版本都装有disk,包括linux的resure模式下的依然能够使用. fdisk是一个机遇MBR的分区工具,所有如果 ...
- day03.1-函数编程
python中函数的定义: def test (x,y): "The function definitions" z = x**y return z ""&qu ...
- A. The Meaningless Game(数学)
A. The Meaningless Game time limit per test:1 second memory limit per test:256 megabytes input:stand ...
- 在Java中如何优雅地判空
判空灾难 作为搬砖党的一族们,我们对判空一定再熟悉不过了,不要跟我说你很少进行判空,除非你喜欢NullPointerException. 不过NullPointerException对于很多猿们来 ...
- bzoj2754:[SCOI2012]喵星球上的点名(后缀自动机)
Description a180285幸运地被选做了地球到喵星球的留学生.他发现喵星人在上课前的点名现象非常有趣. 假设课堂上有N个喵星人,每个喵星人的名字由姓和名构成.喵星球上的老师会选择M个串 ...
- threading.local()方法;线程池
一,threading.local() import time import threading v = threading.local() def func(arg): # 内部会为当前线程创建一个 ...
- python的数据结构分类,以及数字的处理函数,类型判断
python的数据结构分类: 数值型 int:python3中都是长整形,没有大小限制,受限内存区域的大小 float:只有双精度型 complex:实数和虚数部分都是浮点型,1+1.2J bool: ...
- ArchLinux中证书错误解决方案
ca-certificates 更新 x509: failed to load system roots and no roots provided. curl error: Problem with ...
- linux性能评估与分析工具---CPU篇
一. uptime root@calm:~# uptime :: up days, :, user, load average: 0.04, 0.09, 0.04 这里主要关注load average ...
- Oracle 中wmsys.wm_concat拼接字符串,结果过长报错解决
备忘:这个函数最大是4000,根据拼接列的长度,通过限制拼接条数来防止拼接字符串过长错误 --这个情况是从子表中读取出具,这里直接把它当做查询字段处理,在子表中有所有数据 select info.id ...