简体   繁体   中英

How to fetch Response from Post Message

i have been working on trello api so my issue is that i have to save a token in database. response is in post message :

 window.opener.postMessage("token generated here ", "http://www.servername.com")

 1. how  to fetch token from post message.
 2.i have tried code from this link :http://stackoverflow.com/questions/3332532/how-can-i-do-cross-domain-postmessage. but is not working.
 3. https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage this link i also go through .

    snapshots step by step here is
    step 1: authentication with oath  :http://postimg.org/image/5cwazfvfv/
    step 2: when i press allow  button to get token  i recieve this window and here 
     url: http://postimg.org/image/f3y34m2dz/

As I know, postmessage is asynchornious. Consequently, it's hard to capture which message is returned to which source parent/window. I think we can consider 2 things as below:

  1. It's reasonable define how to determine which target window (instead of "*" indicator). In my case, we can temporary use like that: frameA.contentWindow.postMessage(msg, frameA.src). However, my solution still face problem if we need to support many frame has the same href.
  2. The second thing is needed to point out which target page will received/handle returned value from frame. As above thing, my solution is rely on origin property of event object (used for Chrome/Safari browser for instance. In case other versions/browser, we need use corresponding property).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM