Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

javascript - 无法在'DOMWindow'上执行'postMessage':https://www.youtube.com!== http:// localhost:9000(Failed to execute 'postMessage' on 'DOMWindow': https://www.youtube.com !== http://localhost:9000)

This is the error message that I get:

(这是我得到的错误消息:)

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('https://www.youtube.com') does not match the recipient window's origin 
('http://localhost:9000').

I've seen other similar problems where the target origin is http://www.youtube.com and the recipient origin is https://www.youtube.com , but none like mine where the target is https://www.youtube.com and the origin is http://localhost:9000 .

(我已经看到其他类似的问题,目标来源是http://www.youtube.com ,收件人来源是https://www.youtube.com ,但没有一个像我的目标是https://www.youtube.com和原点是http://localhost:9000 。)

  1. I don't get the problem.

    (我没有遇到问题。)

    What is the problem?

    (问题是什么?)

  2. How can I fix it?

    (我该如何解决?)

  ask by Adam Zerner translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I believe this is an issue with the target origin being https .

(我认为这是目标来源为https 。)

I suspect it is because your iFrame url is using http instead of https .

(我怀疑是因为你的iFrame网址使用的是http而不是https 。)

Try changing the url of the file you are trying to embed to be https .

(尝试将您要嵌入的文件的网址更改为https 。)

For instance:

(例如:)

'//www.youtube.com/embed/' + id + '?showinfo=0&enablejsapi=1&origin=http://localhost:9000';

to be:

(成为:)

'https://www.youtube.com/embed/' + id + '?showinfo=0&enablejsapi=1&origin=http://localhost:9000';

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...