Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding YouTube Videos doesn't work in local HTML files (using file:// URL)

Tags:

html

youtube

web

Why does embedding videos from youtube work on my local host but not when it is in C drive

eg: http://localhost/test/test.html                (embedded video works ) 

file:///C:/Users/AUser%20name/Desktop/test/test.html  (embedded video does not work)

this is my snippet of code to embedd the video

<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>
like image 700
user2284926 Avatar asked Dec 05 '25 19:12

user2284926


1 Answers

Because you use the // at the beginning of the url, meaning you inherit the currently used protocol. At your host it is http:// (good), but at your C drive it's file:// (bad).

So just use http:// instead of //:

<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>
like image 198
seymar Avatar answered Dec 08 '25 12:12

seymar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!