无法执行“postMessage的'对'DOMWindow'!https://www.youtube.com == HTTP://本地主机:9000 [英] Failed to execute 'postMessage' on 'DOMWindow': https://www.youtube.com !== http://localhost:9000
问题描述
这是我得到的错误消息:
未能执行postMessage的'对'DOMWindow:提供的目标原点
(https://www.youtube.com')不匹配收件人窗口的原点
(的http://本地主机:9000')。
我见过的其他类似问题,其中目标原点是 http://www.youtube.com
和收件人的起源是 HTTPS: //www.youtube.com
,但没有一个像我所在的目标为 https://www.youtube.com
和原产地是的http://本地主机:9000
- 我不明白的问题。有什么问题?
- 我怎样才能解决这个问题?
我相信这是与目标原点是 HTTPS
的问题。我怀疑这是因为你的iframe网址中使用 HTTP
而不是 HTTPS
。试着改变你正在试图嵌入是文件的URL HTTPS
。
例如:
VAR ID =的getId(URL);
回报//www.youtube.com/embed/'+ ID +'showinfo = 0&安培; enablejsapi = 1&安培;起源=的http://本地主机:9000';
}
是:
VAR ID =的getId(URL);
回报https://www.youtube.com/embed/'+ ID +'showinfo = 0&安培; enablejsapi = 1&安培;起源=的http://本地主机: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
.
- I don't get the problem. What is the problem?
- How can I fix it?
I believe this is an issue with the target origin being https
. I suspect it is because your iFrame url is using http
instead of https
. Try changing the url of the file you are trying to embed to be https
.
For instance:
var id = getId(url);
return '//www.youtube.com/embed/' + id + '?showinfo=0&enablejsapi=1&origin=http://localhost:9000';
}
to be:
var id = getId(url);
return 'https://www.youtube.com/embed/' + id + '?showinfo=0&enablejsapi=1&origin=http://localhost:9000';
}
这篇关于无法执行“postMessage的'对'DOMWindow'!https://www.youtube.com == HTTP://本地主机:9000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!