dimanche 29 novembre 2020

How to reset document.domain to original value?

I have a situation where earlier in the code when the page loads, document.domain was set to a parent domain value (eg - from a.xyz.com to xyz.com).

Due to this I am not able to access the document object inside my iframe (document.getElementById('iframe-tnc').contentDocument.document) whose origin is a.xyz.com. The browser throws cross domain error because it check the current documnet.domain (xyz.com) with the iframe origin (a.xyz.com).

As a solution to this problem, I want to reset the document.domain value to the original value of a.xyz.com. Just doing document.domain=a.xyz.com will not work because the port value stored internal in the browser is reset to null and it is not set back to 80/443. ref - https://stackoverflow.com/a/1525312/1298824

How do I reset the document.domain to the original value including the internal port value? I would want it to be reset to a.xyz.com,80/443.

Note - I do not have access to codebase of iframe src page to set the document.domain value in that page.




Aucun commentaire:

Enregistrer un commentaire