Skip to content

Incorrect information regarding access to the document of the iframe #3559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions 3-frames-and-windows/03-cross-window-communication/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,16 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
*!*
let iframeWindow = iframe.contentWindow; // OK
*/!*
try {
// ...but not to the document inside it

// ...but when we try to access the document

*!*
let doc = iframe.contentDocument; // ERROR
let doc = iframe.contentDocument; // ...we'll get null
*/!*
} catch(e) {
alert(e); // Security Error (another origin)
}

// also we can't READ the URL of the page in iframe
try {
// Can't read URL from the Location object
// can't read URL from the Location object
*!*
let href = iframe.contentWindow.location.href; // ERROR
*/!*
Expand All @@ -77,7 +75,7 @@ For instance, let's try reading and writing to `<iframe>` from another origin:
</script>
```

The code above shows errors for any operations except:
The code above shows `null` or error for any operations except:

- Getting the reference to the inner window `iframe.contentWindow` - that's allowed.
- Writing to `location`.
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy