zoukankan      html  css  js  c++  java
  • node-webkit 新建实例窗口间通信问题解决办法

    终于弄明白这问题了,只要在js文件里加上段代码,就可解决两窗口间通信问题。

     var str = {
     username: User.name,
     userrole: User.role
     };
     var new_win = gui.Window.get(
    window.open('home.html', {focus: true})
     );
     new_win.on('loaded', function (User) {
     new_win.window.window.str = str;
         new_win.window.window.document.getElementById('msg').innerHTML="登录成功,用户名:" + str.username + ",用户角色:" +str.userrole;
     });

     1、在B页面中可以使用window.opener获得A页面的window句柄,使用该句柄即可调用A页面中的对象,函数等。例如A页面定义js函数onClosePageB,在B页面可以用window.opener.onClosePageB来进行回调。
    2、使用 window.showModalDialog(sURL [, vArguments] [,sFeatures])打开新窗口。
    其中vArguments 参数可以用来向对话框传递参数。传递的参数类型不限,包括数组、函数等。对话框通过window.dialogArguments来取得传递进来的参数。
    3、如果是支持HTML5的话,建议用本地存储(local storage),它支持一个事件方法window.onstorage,只要其中一个窗口修改了本地存储,其他同源窗口会触发这个事件。

  • 相关阅读:
    内存映射mmap的几个api及其使用
    hiredis的安装
    Linux 下解压大全
    redis内存数据库C客户端hiredis API 中文说明
    C/C++使用MySQL
    搜索引擎的缓存(cache)机制
    快速排序(QuickSort)
    冒泡排序
    spring核心之AOP学习总结一
    Spring学习总结六——SpringMVC一
  • 原文地址:https://www.cnblogs.com/zzt-lovelinlin/p/4528628.html
Copyright © 2011-2022 走看看