zoukankan      html  css  js  c++  java
  • window.parent与window.openner区别介绍

    转自http://www.jb51.net/article/30086.htm

    首先来说说 parent.window与top.window的用法 
    "window.location.href"、"location.href"是本页面跳转 
    "parent.location.href"是上一层页面跳转 
    "top.location.href"是最外层的页面跳转 
    举例说明: 
    如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写 
    "window.location.href"、"location.href":D页面跳转 
    "parent.location.href":C页面跳转 
    "top.location.href":A页面跳转 
    现在终于明白了连接的时候target的用法了: 
    _blank:重新打开一个窗口 
    _parent:父窗口执行重定向 
    _self:自身页面重定向 
    _top:第一个父窗口重定向 
    综上所述可知:parent.window:父窗口对象 top.window:第一个父窗口的对象 
    下面来重点看看window.parent与window.openner区别 
    window.parent 是iframe页面调用父页面对象,当我们想从iframe内嵌的页面中访问外层页面是可以直接利用window.parent获取; 

    下面来举几个常用的例子: 
    parent.window与top.window一般在分割的页面即 frameset或iframe中使用 
    注销整个框架后返回到login.aspx:parent.window.location='Login.aspx'或者 
    top.window.location='Login.aspx' 
    window.parent也是常在框架中使用, 
    刷新:window.parent.location.reload();或者刷新某个框架:window.parent.MainForm.location.reload(); 
    获得其他框架的元素值:window.parent.MainForm.form1.text1.value; 
    window.opener主要是获得通过超链接或者 window.open() 打开本身页面的页面的一些,比如获得值,刷新等 
    刷新:window.opener.location.reload(); 
    获值:window.opener.document.getElement("txtName").value; 
    后退:top.playFrame.history.go(-1); 
    前进: top.playFrame.history.go(1); 
    刷新: top.playFrame.location.reload(); 
    就总结到这里,这些对象很实用

  • 相关阅读:
    OleDbConnection SqlConnection DB2Connection 区别
    网站软件FTP下载
    总结方法论
    面向对象的三大基石(封装,继承和复合,多态)
    wkhtmltopdf中文参数
    HTTP协议的8种请求类型介绍
    枚举操作笔记
    自写任务调度模型
    数据库操作类
    LoadRunner录制后无法自动生成脚本
  • 原文地址:https://www.cnblogs.com/Janejxt/p/5405440.html
Copyright © 2011-2022 走看看