Issue communication with postMessage from parent to child iFrame

前端 未结 2 976
青春惊慌失措
青春惊慌失措 2021-01-12 21:36

I\'m having an issue communicating from my parent window to the child iFrame. But in the other side, everything works perfectly. Here is how I get the chil iFrame object in

2条回答
  •  情深已故
    2021-01-12 22:05

    Below code also works.

    $('#id')[0].contentWindow.postMessage("hello world",targetOrigin);

    There is a difference between jQuery selector and document.getElementById.

    Document.getElementByID returns HTML DOM object.
    jQuery selector returns jQuery object.

    For more information please find below link. document.getElementById vs jQuery $()

提交回复
热议问题