postmessage

详解浏览器跨域

被刻印的时光 ゝ 提交于 2019-11-30 03:30:03
一、什么是跨域? JavaScript出于 安全 方面的考虑做的 同源 策略的 限制 ,不允许 跨域 访问其他资源。通常跨域请求成功后,浏览器会拒绝响应服务器端返回的结果。 1.出于哪些方面的安全考虑? 同源政策的目的是为了防止恶意网站窃取用户数据信息冒充用户做一些操作。同源限制只是提高攻击成本。如果没有JavaScript同源限制: (1)CSRF攻击 (2)XSS攻击 2.什么是同源? 域名、协议、端口均相同。举例来说, http://www.example.com/dir/page.html 这个网址,协议是 http:// ,域名是 www.example.com ,端口是 80 (默认端口可以省略) 3.做了哪些限制? (1)Window对象之间的跨源通信:无法读取Cookie( cookie是只会区分域名,不会区分端口的,所以在处理cookie 的时候必须首先你自己为cookie加上端口的标示以便区分。这里要感谢评论区指正的道友 )、LocalStorage 、IndexDB 和获取DOM,但通过以下标签可以跨域访问资源: <img src="URL"> <link href="URL"> <script src="URL"> <iframe src="URL"> <form action="URL" method="get/post"> First name:

window.postmessage() to communicate between applications in different tabs

送分小仙女□ 提交于 2019-11-29 23:53:10
问题 Is there a chance to use window.postmessage() to communicate between two different applications in different tabs in the same browser? I know you can do it between application and iFrame, but how about different tabs? Update: Case scenario: user plays audio from vk.com in one tab user starts playing video from youtube.com in another tab youtube.com sends postmessage() to vk.com that video started playing vk.com makes audio silent Thanks 回答1: It can be done if you use an "intermediate page"

WK 与 JS 的那些事 WKWebView使用

ⅰ亾dé卋堺 提交于 2019-11-29 23:13:49
苹果在iOS 8中推出了 WKWebView ,这是一个高性能的 web 框架,相较于 UIWebView 来说,有巨大提升。本文将针对 WKWebView 进行简单介绍,然后介绍下如何和 JS 进行愉快的交互。还望各位大佬不吝赐教。 本文分为两大部分 WKWebView 简单介绍 JS 交互 1 WKWebView 就目前移动开发趋势来说,很多 APP 都会嵌套一些 H5 的应用。H5 有一些 Native 无法比拟的优势,例如:更新快,不用发版,随时上线等等。然而在 iOS 中, UIWebView 是及其难用的。随着 iOS 8 的推出,Apple 重构了 UIWebView,于是 WKWebView 横空出世。 1.1 WKWebView VS UIWebView 根据官方文档,我们来简单对比一下 UIWebView 和 WKWebView,看看这两个到底有什么区别 WKWebView UIWebView 内存占用 小 大 且有内存泄漏 加载速度 快 慢 与 JS 交互 易 难 (可与 JSCore 配合) 帧率 60FPS 掉帧 从文档来看,二者区别还是很明显的,但到底区别有多大的,我们用数据说话。打开京东,网易,新浪这三个网站,从打开时间和占用内存上来比较一下,看谁能胜出。该测试在 2015款 MBP 上打开,使用 Xcode 9 GM 版,在 iPhone 8

转载:浏览器跨域介绍

廉价感情. 提交于 2019-11-29 18:05:01
转自: https://my.oschina.net/u/4203303/blog/3102954 一、什么是跨域? JavaScript出于 安全 方面的考虑做的 同源 策略的 限制 ,不允许 跨域 访问其他资源。通常跨域请求成功后,浏览器会拒绝响应服务器端返回的结果。 1.出于哪些方面的安全考虑? 同源政策的目的是为了防止恶意网站窃取用户数据信息冒充用户做一些操作。同源限制只是提高攻击成本。如果没有JavaScript同源限制: (1)CSRF攻击 (2)XSS攻击 2.什么是同源? 域名、协议、端口均相同。举例来说, http://www.example.com/dir/page.html 这个网址,协议是 http:// ,域名是 www.example.com ,端口是 80 (默认端口可以省略) 3.做了哪些限制? (1)Window对象之间的跨源通信:无法读取Cookie、LocalStorage 、IndexDB 和获取DOM,但通过以下标签可以跨域访问资源: <img src="URL"> <link href="URL"> <script src="URL"> <iframe src="URL"> <form action="URL" method="get/post"> First name: <input type="text" name="fname">

Web Worker 使用教程【转】

試著忘記壹切 提交于 2019-11-29 16:08:16
原文:http://www.ruanyifeng.com/blog/2018/07/web-worker.html 一、概述 JavaScript 语言采用的是单线程模型,也就是说,所有任务只能在一个线程上完成,一次只能做一件事。前面的任务没做完,后面的任务只能等着。随着电脑计算能力的增强,尤其是多核 CPU 的出现,单线程带来很大的不便,无法充分发挥计算机的计算能力。 Web Worker 的作用,就是为 JavaScript 创造多线程环境,允许主线程创建 Worker 线程,将一些任务分配给后者运行。在主线程运行的同时,Worker 线程在后台运行,两者互不干扰。等到 Worker 线程完成计算任务,再把结果返回给主线程。这样的好处是,一些计算密集型或高延迟的任务,被 Worker 线程负担了,主线程(通常负责 UI 交互)就会很流畅,不会被阻塞或拖慢。 Worker 线程一旦新建成功,就会始终运行,不会被主线程上的活动(比如用户点击按钮、提交表单)打断。这样有利于随时响应主线程的通信。但是,这也造成了 Worker 比较耗费资源,不应该过度使用,而且一旦使用完毕,就应该关闭。 Web Worker 有以下几个使用注意点。 (1) 同源限制 分配给 Worker 线程运行的脚本文件,必须与主线程的脚本文件同源。 (2) DOM 限制 Worker 线程所在的全局对象

Why do some applications not accept some sendkeys at some times

六月ゝ 毕业季﹏ 提交于 2019-11-29 12:55:58
This is an issue I've ran into before, but I've always given up solving the problem and worked out a work around. Not today (hopefully). I'm trying to make a bot for the classic Doom II. I want my bot to have access to the main menu which is accessed via the escape key. Naturally I tried: sendkeys.send("{ESC}") No luck. But then something weird happened. I accidently ran the code when I was already on the menu... and it closed the menu (which is normal if you press escape on the menu). So clearly Doom II listens to Sendkeys. I've since tried sendinput, postmessage, and simulateinput. None have

PostMessage from WorkerThread to Main Window in MFC

房东的猫 提交于 2019-11-29 10:21:55
I have a MFC application, which has a worker thread, what I want to do is to post message from worker thread to the Main GUI thread to update some status messages on GUI. What I have done so far is Registered a new window message //custom messages static UINT FTP_APP_STATUS_UPDATE = ::RegisterWindowMessageA("FTP_APP_STATUS_UPDATE"); Added this message to the message map of dialog class ON_MESSAGE(FTP_APP_STATUS_UPDATE, &CMFC_TestApplicationDlg::OnStatusUpdate) The prototype of OnStatusUpdate is afx_msg LRESULT OnStatusUpdate(WPARAM, LPARAM); and definition is LRESULT CMFC_TestApplicationDlg:

C# - How to PostMessage to a flash window embedded in a WebBrowser?

前提是你 提交于 2019-11-29 07:42:07
I would like to know if there was any way to lock onto a Flash window and post a message to it? Another person here had the answer to it, his name is Spencer K. His question was: Sending simulated click via WebBrowser in C# to flash object embedded in HTML Unfortunately, Mr. K wasn't very specific, and all he left behind for people reading his question was that he "got the handle and then iterated through the handles." I'm not extremely sure what he meant by that. I iterated through all visible handles using EnumWindows to no avail, as that did not return a window that was a flash window. I

Ajax 浏览器跨域访问控制

蹲街弑〆低调 提交于 2019-11-29 05:18:58
jsonp+ajax实现浏览器跨域通信的原理解析 php+ajax+P3P实现多域名跨域登录 一.关于跨域需要设置的响应头消息 Access-Control-Allow-Origin:* #允许所有主机 Access-Control-Allow-Origin:http://hello-world.example #允许特定主机 Access-Control-Allow-Methods: POST, GET, OPTIONS #允许跨域执行的方法 Access-Control-Allow-Headers: X-PINGOTHER,Content-Type,MyHeader #允许跨域设置的头信息(如果不设置,那么无法获取该值,甚至数据无法获取) Access-Control-Max-Age: 1728000 二.关于IE8和IE9浏览器差异性说明 IE8和IE9使用新的API XDomainRequest(IE又淘气了一次,但还好IE7上可以通过ajax跨域) var xdr = new XDomainRequest(); xdr.onload = function (e) { //当收到服务器响应的回调函数 var data = $.parseJSON(xdr.responseText); if (data == null || typeof (data) ==

Detect whether postMessage can send objects?

末鹿安然 提交于 2019-11-29 03:36:18
问题 I'm looking for a neat way to detect whether postMessage in the browser supports the sending and receiving of objects or just strings. I figure that someone out there must have wrote something that does this but I have not managed to find a solution. I'm using postMessage to send data to/from a WebWorker. Whilst detecting whether the browser supports workers is straight-forward, detecting whether objects can be send via postMessage has proved more difficult. I'd like to write a simple