嵌入YouTube视频无法在本地HTML文件中使用(使用file:// URL)

use*_*926 3 html youtube web

为什么嵌入来自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)
Run Code Online (Sandbox Code Playgroud)

这是嵌入视频的代码片段

<object width="560" height="315"><param name="movie" value="//www.youtube.com/v/0l-
7IGRsORI?hl=en_US&amp;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&amp;version=3" type="application/x-
shockwave-flash" width="560" height="315" allowscriptaccess="always"
allowfullscreen="true"></embed></object>
Run Code Online (Sandbox Code Playgroud)

Sti*_*ens 7

因为您//在url的开头使用,这意味着您继承了当前使用的协议.在你的主人那是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&amp;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&amp;version=3" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>
Run Code Online (Sandbox Code Playgroud)