在项目开发中我们经常会遇到弹窗,有的是通过div模拟弹窗效果,有的是通过iframe,也有通过window自带的open函数打开一个新的窗口。今天给大家分享的是最后一种通过window.open()函数打开页面进行数据交互。首先看下效果图:

父窗口给子窗口传递数据是通过url的参数传递过去,子窗口给父窗口传递数据是通过父窗口的全局函数传递。
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="content"></div> <button id="test">按钮</button> <script> var test = document.getElementById('test'); test.onclick = function() { window.open('./window.html?param1=name¶m2=password', '_blank','width=960,height=650,menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes'); }; window.getContent = function(tx) { document.getElementById('content').innerText = tx; } </script> </body> </html>
window.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="content"></div> <select name="" id="city"> <option value="shanghai">上海</option> <option value="hangzhou">杭州</option> </select> <script> var params = location.href.substring(location.href.lastIndexOf('?')+1).split('&'); document.getElementById('content').innerText = params; var city = document.getElementById('city'); city.onchange = function() { window.opener.getContent(city.value); } </script> </body> </html>
注意:要有服务环境
来源:https://yq.aliyun.com/articles/392553
前言 : 由于程序应用在IE上使用,便于IE结下缘分了。 1.发现问题 :随着使用次数的增加,IE点击链接弹新建窗口就浮出水面了,下面来跟着节奏来解决它(看下图起因)。 2.解决方案 : 在百度上找到的方法,加上亲手操作可行! 2.1 在IE中找到 工具 —— Internet 选项 —— 常规 —&mda...
window对象的open()方法,创建新的浏览器窗口。这个方法有三个参数:window.open(url,name,features) 第一个参数:新窗口的地址; 第二个参数:新窗口的名字,可以在代码里通过这个名字与新窗口进行通信; 第三个参数:新窗口的各种属性(宽度,高度等); 案例代码如下: ...
前段时间一直想学学微信中的小程序是如何制作的,昨天终于有时间就尝试了一下。话不多说,以免跑偏。。。。 1.微信小程序开发需要先在微信公众平台(https://mp.weixin.qq.com)上注册一个自己的公众号。 2.在公众平台上注册成功后,在公众号左侧有一个小程序栏目。点击小程序管理,在左侧就会出现两个选项,在第一次使用小程序当然是没有小程序账号的,点击右侧注册小...
参考链接: Win10+VS2015环境下安装编译PCL1.8.1和VTK8.0.0(踩坑大全)https://blog.csdn.net/weixin_39871164/article/details/102879962 1.vs2017编译安装VTK (PCL点云显示是基于VTK做的) - PCL191匹配的VTK版本是VTK8.1(PCL191\3rdParty\VTK\include\vt...
一、union注入 基于union的信息获取: union联合查询:可以通过联合查询来查询指定的数据 用法举例: select username,password from user where id =1 union select 字段1,字段2 from 表名 先登入PHPmyadmin 进入pikachu的数据库中 得到此结果 上述为一般查询 union查询: 除了通过遍历查询数据库内容外,...
String常用的几个方法介绍 首先在讲之前我想说几句题外话,关于string的常用方法我查了很久csdn,我发现要不就是一大坨,还有一些乱七八糟的拓展,看的你一脸懵逼,要不就是简洁的很,该写的你不写出来,所以搞得你很难受。但是在你看了我这篇文章以后我觉得你可能会缓解很多,那就开始吧。 String的方法是有很多的,这里我只列举一些我常用的,喷子不要喷。 直接上代码先。 方法一:charAt: 很...
本次得分为:15.00/15.00, 本次测试的提交时间为:2020-04-24, 如果你认为本次测试成绩不理想,你可以选择再做一次。 【第5章 测试(下)】 1单选(1分) 下图可以表示哪种控制方式的CPU工作效率?选A 得分/总分 A. DMA方式 1.00/1.00 B.无正确答案 C.程序中断方式 D.程序查询方式 2单选(1分) 在程序中断方式下,中断响应发生在__B_ 得分/总分 A....
一、题目描述 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。 示例 3: 输入: 10 输出: false 解释: 从右向左读, 为 01 。因此它不是一个回文数。 进...
一,使用斜体的情况: 1) 变量(variables)应该用斜体表示:例如T表示温度(temperature),r表示速率(rate). 注意:即便用变量来作为形容词的组成部分,依然要保持斜体, 举例:In this equation, is the frequency of the th mode. 2) 坐标轴(a...
1、进入docker hub镜像仓库地址:https://hub.docker.com/ 2、搜索rabbitMq,进入官方的镜像,可以看到以下几种类型的镜像;我们选择带有“mangement”的版本(包含web管理页面); 3、拉取镜像 使用:docker images 查看所有镜像 4、根据下载的镜像创建和启动容器 说明: -d 后台运行容器;...
I am using a MultiInput control to which I am adding Tokens based on input from the user. For this I have used addValidator function to add Token with 'key' and 'text'. I am looking to add operator (l...
I am trying to make a request in a document with mongodb. In this document I'm looking to get just the id in friend, not all of the document just 1 id in friend with where i try this : It's not workin...
How can i use Rspec Expectations in Page-object classes. I need to assert elements. Currently i am using xpath, other locators to check element existence. I know using it is step definitions. But i ne...
I'm writing network application in c++ and I want to enable making plugins, but I don't know what to do, to protect my application from errors like segfault. For example: I have interface: And someone...
I've an anchor in an Asp.Net user control. I've wired some code to the onclick event. For some reason in Internet Explorer 10, the event is not firing. The markup is structured as where myFunction is ...