Search code examples
htmliframeyoutubeembedhtml-object

Youtube embeded video not working in all my browsers: FireFox, IE and Chrome


I'm trying to embed a video into my webpage which has a hide/show div function, the hide/show div works but the embedded video doesn't, in Firefox when I click on the text that shows the div with the contained YouTube video it just shows a black patch (I think that's because that's the colour of my back-ground) but if I launch it in Chrome it shows a white box saying that the webpage cannot be found, and IE says that it cant find the webpage as well.

I copied the embed code straight from the YouTube video its self from the share button, its using the '<iframe>' tag rather than the '<object>' tag, I'm not sure if that has anything to do with it.

Here is the embed code of the video I wish to embed:

<iframe width="640" height="360" src="//www.youtube.com/embed/1qNQHv6jdyY?rel=0" frameborder="0" allowfullscreen></iframe>

And here is my webpage so far (not finished yet):

<!DOCTYPE HTML>

<HTML>
<HEAD>
<TITLE>Index</TITLE>

<link rel="stylesheet" type="text/css" href="DubWin By Chris Mckee-Rogers.css">

<SCRIPT type="text/javascript">
function toggleShowHide(elementId) {
var element = document.getElementById(elementId);
if (element) {
    if (element.style.display == "none")
        element.style.display = "inline";
    else
        element.style.display = "none";
}
}
</SCRIPT>

</HEAD>
<BODY>

<div class="Container">
<img src="images/logo.png" alt="Logo">
<div class="Menu">
<a href="Index.html">Home</a> | <a href="artist-info.html">Artists Information</a> | <a href="songs-and-mixes.html">Songs And Mixes<a> | <a href="forms.html">Forms<a>
</div>

<DIV class="Con-text">
<h1 style="text-align: center;">Here you'll be able to hear a few of my personal selected mixes and tunes</h1>

<h2 onClick="toggleShowHide('12th Planet')">12th Planet</h2>
<div id="12th Planet" style="display:none">
<iframe width="640" height="360" src="//www.youtube.com/embed/1qNQHv6jdyY?" frameborder="0" allowfullscreen></iframe>
</div>
<br>
<h2 onClick="toggleShowHide('Bar 9')">Bar 9</h2>
<div id="Bar 9" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Bassnectar')">Bassnectar</h2>
<div id="Bassnectar" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Chase & Status')">Chase & Status</h2>
<div id="Chase & Status" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Digital Mystikz')">Digital Mystikz</h2>
<div id="Digital Mystikz" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('DJ Fresh')">DJ Fresh</h2>
<div id="DJ Fresh" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Doctor P')">Doctor P</h2>
<div id="Doctor P" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Flux Pavillion')">Flux Pavillion</h2>
<div id="Flux Pavillion" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Foreign Beggars')">Foreign Beggars</h2>
<div id="Foreign Beggars" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Gemini')">Gemini</h2>
<div id="Gemini" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Going Quantum')">Going Quantum</h2>
<div id="Going Quantum" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Kryptic Minds')">Kryptic Minds</h2>
<div id="Kryptic Minds" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Magnetic Man')">Magnetic Man</h2>
<div id="Magnetic Man" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('ModeStep')">ModeStep</h2>
<div id="ModeStep" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Mt Eden')">Mt Eden</h2>
<div id="Mt Eden" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Nero')">Nero</h2>
<div id="Nero" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Pendulum')">Pendulum</h2>
<div id="Pendulum" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Rusko')">Rusko</h2>
<div id="Rusko" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Skrillex')">Skrillex</h2>
<div id="Skrillex" style="display:none">

</div>
<br>
<h2 onClick="toggleShowHide('Sub Focus')">Sub Focus</h2>
<div id="Sub Focus" style="display:none">

</div>

</DIV>

</div>
<br>

</BODY>
</HTML>

Thanks for all of your help.


Solution

  • Youtube uses //www to be compliant if you're using both http:// and https:// - it works fine if you run it via a webserver locally, ie WAMP on Windows, but not if you just open the file in the browser with the file://

    Reference - Two forward slashes in a url/src/href attribute