
219
function showElm(name) {
var elm = document.getElementById(name);
if (elm) { elm.style.display = "block"; }
}
function hideElm(name) {
var elm = document.getElementById(name);
if (elm) { elm.style.display = "none"; }
}
As you can see, the showVideo function hides the “expander” element but shows the “expandee”
element. It will then ll the “expandee” element with the YouTube embed code, and also add a link
reading “Hide video” to collapse the video again. The height and width of the player in this example
are slightly adjusted to be a bit larger than the default size, but there’s another specialty with this
embed code: it carries the “autoplay=1” ag, because you don’t want your visitors to have to click
the play button once more when they've already clicked your “Show video” link.
What happens when the user now presses the “Hide video” link? The following JavaScript will be
triggered—and this time, the video buffer stops loading, too, at least in the popular browsers that
this has been tested with:
function hideVideo(n, videoId) {
var elm = document.getElementById("expandee" + n);
if (elm) {
elm.innerHTML = " ";
}
showElm("expander" + n);
hideElm("expandee" + n);
}
HaCK 90:
Allow video viewers to get the message of your lm even without
hearing any sound. This can be suitable both for hearing-impaired
viewers as well as people who watch your videos ...