postmessage

Asynchronous communication cross pages

杀马特。学长 韩版系。学妹 提交于 2020-01-24 22:15:19
问题 I have a page addin.html . It can popup another page editor (which is not necessarily in the same domain) by popup = window.open("https://localhost:3000/#/posts/editor/", "popup") Then, the two pages have each one listener inside, and can send data to each other by // listen: function receiveMessage(event) { document.getElementById("display").innerHTML = JSON.stringify(event.data); } window.addEventListener("message", receiveMessage, false); // send: function sendMessage() { popup.postMessage

Iframe简单探索以及Iframe跨域处理

故事扮演 提交于 2020-01-21 20:58:22
探索Iframe 本文目的: Iframe简单使用 Iframe跨域 Iframe常见问题 一.Iframe基本Dom以及常用属性和常用事件 1.DOM: <iframe class="iframe" style="height: 100%;width: 100%;border: 0;" id="Yiframe" name="Yiframe" src='http://localhost:2255/67iframe-2.html' ></iframe> 2.常用属性: 和平时使用的DOM标签类似,样式之类的还是建议用class吧,统一起来方便管理。 更多属性看: http://www.runoob.com/tags/ta... 3.常用事件: <iframe> 标签支持 HTML 的事件属性 。 一般用这个就够了 onload:当文档加载时运行脚本 document.querySelector('#Yiframe').onload = function(event){ console.log('onload',event); } 二.JS动态新增并插入Iframe 和平时新增DOM标签一样即可。 var iframe = document.createElement('iframe'); iframe.src = url; iframe.id = "Yiframe"; iframe

VC 在子线程中结束主窗口程序

守給你的承諾、 提交于 2020-01-21 16:05:05
在MFC 中,创建一个子线程,若想在子线程中退出主窗口程序,可使用PostMessage 向主窗口发送close 或者quit 消息。 BOOL CHandBoxComDlg::OnInitDialog() { g_pThread= AfxBeginThread(ThreadRdFromHandBox, (LPVOID)this); } UINT ThreadRdFromHandBox(LPVOID pParam) { CHandBoxComDlg* pParent=(CHandBoxComDlg*)pParam; pParent->PostMessage(WM_CLOSE,NULL,NULL);//exit } 来源: https://www.cnblogs.com/small-lazybee/p/12221881.html

Vue进阶(九十二):窗口间通信postMessage

我是研究僧i 提交于 2020-01-19 19:18:42
在前端应用中,窗口间的通信用的地方还是挺多的,比如弹出qq登录认证窗。 postMessage语法 window.postMessage(msg,targetOrigin) 注意 postMessage 要通过window对象调用!因为这里的window不只是当前window,大部分使用postMessage的时候,都不是本页面的window,而是其他网页的window!如: iframe的contentWindow 通过window.open方法打开的新窗口的window window.opener 如果你使用postMessage时没有带window,那么,你就是用的本页面的window来调用了它。 参数说明 msg 这就是要传递的消息了。它可以是一切javascript参数,如字符串,数字,对象,数组,而不是和json一样只局限于字符串。 targetOrigin 这个参数称作“目标域”,注意啦,是目标域不是本域!比如,你想在2.com的网页上往1.com网页上传消息,那么这个参数就是“http://1.com/”,而不是2.com. 另外,一个完整的域包括: 协议,主机名,端口号 。如:http://g.cn:80/ window.open 方法会返回一个窗口对象,使用这个对象可以向子窗口发送消息,而子窗口可以通过 window.opener 向父窗口发送消息,示例如下:

c# PostMessage not sending and no error

自作多情 提交于 2020-01-15 05:33:07
问题 First off, I'm trying to send keyboard input to a background application(A window that does'nt have focus or might not even appear visible to the user). I've verified that the winHandle and constants are correct. Problem is the background application doesn't seem to get the message, UNLESS, I set a breakpoint on the PostMessage() line, and press F10(step over) or F5(Continue) when it gets there, then the keystroke magically gets sent. What gives? Relevant code: [DllImport("User32.Dll",

How can I send keys to inactive DirectX “ePSXe” window?

泄露秘密 提交于 2020-01-14 05:29:24
问题 I need to send a key to an inactive "ePSXe" window using C#. I got the handle of the window using Spy++, but when I used this code to send key "x", I got nothing. What should I do? I tried different values of Msg as 0x0100 , 0x0101 and 0x0102 , but nothing worked. I also tried SendMessage and the results were the same. [DllImport("user32.dll")] public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); private void Send_X(IntPtr p) { PostMessage(p, 0x0100,

javascript - postMessage to sandboxed iframe, why is recipient window origin null?

。_饼干妹妹 提交于 2020-01-12 04:40:10
问题 2 postMessage calls in the test: 1 using an asterisk for targetOrigin, one using the same https url of both the parent and child documents. button 1: $('.iframed')[0].contentWindow.postMessage( messageData , '*' ); button 2: $('.iframed')[0].contentWindow.postMessage( messageData , 'https://myurl.net' ); the iframe element in parent html document, which points to child html file on same domain, in same directory: <iframe name="childFrame" class="iframed" src="child.html" sandbox="allow

C# 挂起 进程 PostMessage使用

不羁岁月 提交于 2020-01-11 14:46:47
#region 暂停进程 //检测进程是否存在 public List<IntPtr> get_pressId(string pressName = "explorer") { List<IntPtr> list = new List<IntPtr>(); //获得进程ID Process[] processes = Process.GetProcesses(); foreach (Process process in processes) { if (process.ProcessName == pressName) { list.Add(process.Handle); } } return list; ////挂起进程 //NtSuspendProcess(ip); ////恢复 //NtResumeProcess(ip); } [DllImport("ntdll.dll")] private static extern uint NtSuspendProcess([In] IntPtr processHandle); [DllImport("ntdll.dll")] private static extern uint NtResumeProcess([In] IntPtr processHandle); #endregion /// <summary> /// js c

Sina微博OAuth2框架解密

▼魔方 西西 提交于 2020-01-09 22:18:00
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 自从sina微博oauth2出来以后, 第三方集成开发简单了很多. Oauth2不像oauth1一样需要后台httpclient请求那么麻烦, 一切都可以在前台使用ajax实现了. 很多人觉得蹊跷, 对于一个第三方应用, 如何不走后台,而在前台使用ajax, 来获取access token? 又如何向sina发起get或post请求? 这其中最难解决的问题当属跨域问题. 这篇文章将彻底解决这些疑问. OAuth OAuth为一种授权认证机制. 它牵扯到服务提供方(sina weibo), 用户, 第三方应用(比如糗事百科). 第三方应用想方便用户可以在它的应用里面直接访问自己的weibo信息,还可以把第三方的信息发送到weibo, 比如转发糗事到sina weibo. 实现这个功能, 首先需要第三方应用拥有用户和sina的授权. 在拿到授权以后,第三方应用才能实现集成功能. 为什么不直接给第三方用户密码而用授权机制, 这种问题就不罗嗦了. 拿糗百为例,授权的过程为: 1, 糗百打开一个window或iframe, location指向weibo oauth授权界面. 2, weibo授权界面是在sina的域名下,是由sina的服务器控制的. 授权界面要求用户填写sina的账户,并确认授权. 3, 用户确认以后,

postMessage Source IFrame

烈酒焚心 提交于 2020-01-09 12:51:16
问题 I'm working on a website with cross-domain iframes that are resized to the correct height using postMessage. The only problem I'm having is identifying which iframe has which height. The way I've currently got it set up is that when one iframe sends its height to the parent, all the iframes' heights are changed. Parent: var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage