CORS solution on client side: postMessage & onMessage

本想做postMessage & onMessage的單元測試,
但因卡在不知怎麼實現不同網域,
找了很久, 覺得這篇文章的範例很好,

範例直接在codepen上: http://codepen.io/matt-west/pen/lpExI

一些語法解釋:

contentWindow: The contentWindow property returns the Window object generated by an iframe element (through the window object, you can access the document object and then any one of the document's elements).

postMessage syntax: otherWindow.postMessage(message, targetOrigin, [transfer]);

資料來源: http://blog.teamtreehouse.com/cross-domain-messaging-with-postmessage



留言

熱門文章