为什么嵌入来自 youtube 的视频在我的本地主机上有效,但在 C 盘中却无效
eg: http://localhost/test/test.html (embedded video works )
file:///C:/Users/AUser%20name/Desktop/test/test.html (embedded video does not work)
这是我嵌入视频的代码片段
<object width="560" height="315"><param name="movie" value="//www.youtube.com/v/0l-
7IGRsORI?hl=en_US&version=3"></param><param name="allowFullScreen" value="true">
</param><param name="allowscriptaccess" value="always"></param><embed
src="//www.youtube.com/v/0l-7IGRsORI?hl=en_US&version=3" type="application/x-
shockwave-flash" width="560" height="315" allowscriptaccess="always"
allowfullscreen="true"></embed></object>
最佳答案
因为你在url开头使用了//
,意味着你继承了当前使用的协议(protocol)。在您的主机上它是 http://
(好),但在您的 C 驱动器上它是 file://
(坏)。
所以只需使用 http://
而不是 //
:
<object width="560" height="315">
<!-- See: value="http://.. -->
<param name="movie" value="http://www.youtube.com/v/0l-7IGRsORI?hl=en_US&version=3"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<!-- See: src="http://.. -->
<embed src="http://www.youtube.com/v/0l-7IGRsORI?hl=en_US&version=3" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>
关于html - 嵌入 YouTube 视频在本地 HTML 文件中不起作用(使用文件 ://URL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17799596/