Home  >  Article  >  Web Front-end  >  javascript浏览器窗口之间传递数据的方法_javascript技巧

javascript浏览器窗口之间传递数据的方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:19:091136browse

本文实例讲述了javascript浏览器窗口之间传递数据的方法。分享给大家供大家参考。具体分析如下:

摘要:

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

原理:

父窗口给子窗口传递数据是通过url的参数传递过去,子窗口给父窗口传递数据是通过父窗口的全局函数传递。

代码:
index.html如下:

复制代码 代码如下:



   
    Document


   

   
   

window.html如下:

复制代码 代码如下:



   
    Document


   

   
   

注意:这里需要有服务环境运行

希望本文所述对大家的javascript程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn