Uncaught SyntaxError: Failed to execute 'postMessage' on 'Window': Invalid target origin 'my_page' in a call to 'postMessage'

前端 未结 1 765
醉梦人生
醉梦人生 2021-02-12 14:25

i have following script

Parent Page(pair_pixel_filter.php):

 window.addEventListener(\"message\", function(e) {
            $(\'#log\')         


        
相关标签:
1条回答
  • 2021-02-12 15:03

    The 2nd parameter to postMessage is the "target origin". This is the domain where the page is located, not the name of the (php) file.

    It needs to be something like:

    window.opener.postMessage(data, "http://example.com");
    

    See: https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage

    0 讨论(0)
提交回复
热议问题