Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect information regarding access to thedocument of theiframe#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Alexandre887 wants to merge1 commit intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromAlexandre887:master-17
Open
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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 showserrors 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

[8]ページ先頭

©2009-2025 Movatter.jp