无法执行“postMessage的'对'DOMWindow'!https://www.youtube.com == HTTP://本地主机:9000 [英] Failed to execute 'postMessage' on 'DOMWindow': https://www.youtube.com !== http://localhost:9000

查看:5609
本文介绍了无法执行“postMessage的'对'DOMWindow'!https://www.youtube.com == HTTP://本地主机:9000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我得到的错误消息:

 未能执行postMessage的'对'DOMWindow:提供的目标原点
(https://www.youtube.com')不匹配收件人窗口的原点
(的http://本地主机:9000')。

我见过的其他类似问题,其中目标原点是 http://www.youtube.com 和收件人的起源是 HTTPS: //www.youtube.com ,但没有一个像我所在的目标为 https://www.youtube.com 和原产地是的http://本地主机:9000


  1. 我不明白的问题。有什么问题?

  2. 我怎样才能解决这个问题?


解决方案

我相信这是与目标原点是 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.

  1. I don't get the problem. What is the problem?
  2. 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆