-
-
Save M3kH/dea521b049ed7377e377 to your computer and use it in GitHub Desktop.
Add at your website you favorite song from You Tube with ?sound=YouTubeViedoCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var st = { | |
urlParam : function(key){ | |
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search); | |
return result && unescape(result[1]) || false; | |
}, | |
appendSound: function(song){ | |
var b = document.getElementsByTagName("body")[0], | |
c = document.createElement('div'); | |
c.innerHTML = '<iframe width="0" height="0" src="//www.youtube.com/embed/'+song+'?autoplay=1&loop=1" frameborder="0"></iframe>'; | |
b.appendChild(c.firstChild); | |
}, | |
init: function(){ | |
var bgSound = st.urlParam("sound"); | |
if(bgSound != false){ | |
st.appendSound(bgSound); | |
} | |
} | |
}; | |
return st.init; | |
}())(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Small demo: http://ideabile.com/?sound=rVqAdIMQZlk (R2D2 - Ghostwriter)