• jquery 获取父窗口的元素 父窗口 子窗口


    一、获取页面元素

    取父窗口的元素方法:$(selector, window.parent.document);

    那么你取父窗口的父窗口的元素就可以用:$(selector, window.parent.parent.document);

    类似的,取其它窗口的方法大同小异

    $(selector, window.top.document);

    $(selector, window.opener.document);

    $(selector, window.top.frames[0].document);

    二、子窗口创建

    javascript 弹出子窗口
    (1) 通过window对象的open()方法,open()方法将会产生一个新的window窗口对象
    其用法为:window.open(URL,windowName,parameters);
    URL: 描述要打开的窗口的URL地址,如何为空则不打开任何网页;
    windowName:描述被打开的窗口的民称,可以使用'_top'、'_blank'等内建名称,这里的名称跟<a href="..." target="...">里的target属性是一样的。
    parameters:描述被打开的窗口的参数值,或者说是样貌,其包括窗口的各个属性值,及要传入的参数值。

    例如:打开一个400 x 100 的干净的窗口:
    open('','_blank','width=400,height=100,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes')
    也可以这样写:var newWindow = open('','_blank');

    参数说明如下:
    top=# 窗口顶部离开屏幕顶部的像素数
    left=# 窗口左端离开屏幕左端的像素数
    width=# 窗口的宽度
    height=# 窗口的高度
    menubar=... 窗口有没有菜单,取值yes或no
    toolbar=... 窗口有没有工具条,取值yes或no
    location=... 窗口有没有地址栏,取值yes或no
    directories=... 窗口有没有连接区,取值yes或no
    scrollbars=... 窗口有没有滚动条,取值yes或no
    status=... 窗口有没有状态栏,取值yes或no
    resizable=... 窗口给不给调整大小,取值yes或no

    三、父窗口与子窗口之间通信

    (1) 使用window.open()创建的窗口与父窗口通信
    可以在子窗口页面中通过window.opener来获取父窗口对象,获取之后子窗口便可以对父窗口执行刷新,传值等操作。
    如:
    window.opener.location.reload(); //子窗口刷新父窗口
    window.opener.location.href //获取父窗口href
    window.opener.locaiton.pathname //获取父窗口路径名
    //刷新父页面
    window.location.href=window.location.href ; //重新定位父页面
    window.location.reload;

  • 相关阅读:
    把影响集中到一个点
    How to avoid Over-fitting using Regularization?
    适定性问题
    Numerical Differentiation 数值微分
    What Every Computer Scientist Should Know About Floating-Point Arithmetic
    Generally a good method to avoid this is to randomly shuffle the data prior to each epoch of training.
    What is the difference between iterations and epochs in Convolution neural networks?
    Every norm is a convex function
    Moore-Penrose Matrix Inverse 摩尔-彭若斯广义逆 埃尔米特矩阵 Hermitian matrix
    perl 类里的函数调用其他类的函数
  • 原文地址:https://www.cnblogs.com/afei-blogs/p/5584359.html
Copyright © 2020-2023  润新知