mdn/dom-examples

onload in iframe.contentWindow is not working ?

liyoung1874 opened this issue · 4 comments

// window is Window object, so
window.onload = () => {
    // This is working
}

// In this document, has a iframe, so
const iframe = document.getElementById('#myIframe')
const iframeWindow = iframe,contentWindow
// iframeWindow is Window object too.

iframwWindow.onload = () => {
    // This is not working.
}

Why is this ? Can explain ?

Thanks so much.

Are you sure the dom is loaded when you call this. And that getElementById worked?

Also there is an incorrect comma in the declaration if iframeWindow.

Is it code copy-pasted from an example? If so which one?

Hello, this case is happening in my work.
This code is my handwrite.

That incorrent comma and selector is my fault. Sorry.

Attach screenshot:

  1. html
    image
  2. js (vue)
    image
  3. debug log
    image
  4. my brower version
    image

Finally, please forgive my English expression.

Sorry, I can't help you more, I don't know about Vue.

You may bring them of a Vue support forum.

We are short in ressources so we cannot do support, but thanks for thinking about us. I'll close this issue.

Thanks for your patient.

But i queit want to know the answer to this question.

So, i use another way to test the case.

There is screenshot.

image