Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-dom): check if iframe belongs to the same origin
The try / catch block doesn't catch cross domain security error but it doesn't affect the code execution flow. This mean that the code after the try / catch block will be executed. We can do the following To check if the parent page has access to the iframe document: ``javascript` let hasAccessToDocument = false; // declare an unitialized variable try { iframe.contentWindow.location.href; // try to access the iframe property hasAccessToDocument = href != null; // This line will be executed if it has access } catch (err) { // Catch block is not executed since the browser throws a cross-domain error } return hasAccessToDocument; // This value will be set to true if the parent page has access to the iframe content. ```
- Loading branch information