window.opener.document.getElementById("parentId1").value = myvalue not working

14,501

is there any issue in communicating with a secure child window and a parent page which is not secure?

Yes. HTTP and HTTPS make for separate script origins. (If they were not separate origins then an unprotected page could script into an HTTPS page and change all its content, defeating the purpose of HTTPS.)

If so how can I solve this issue?

  1. Same origin. Serve the parent page through HTTPS, and either put them on the same hostname or set document.domain to a shared parent domain on both documents.

  2. Cross-origin messaging. window.postMessage; if you need to support older browsers (primarily IE<8) then there are horrible backwards compatibility hacks (like communicating through document.cookie or hash navigation).

  3. Server interaction. One document sends the information to the server and the server shares it back with the other document (eg using XMLHttpRequest).

Share:
14,501
Nidheesh
Author by

Nidheesh

Updated on June 04, 2022

Comments

  • Nidheesh
    Nidheesh almost 2 years

    I was trying to get the value from my child.jsp to my parent.jsp using window.opener.document.getElementById("parentId1").value = myvalue;

    Even though there were no errors found in the console the value is not getting in the parent page.

    The child popup window has the url starting like, https://safe.cresecure.net/securepayments..... and the parent page url starts with http://.... is there any issue in communicating with a secure child window and a parent page which is not secure?

    If so how can I solve this issue?