October 13, 2006 | Web Design & Development
NOTICE: This script has been updated and there is a new version available here. Thanks!
A while back I got the urge to write this for no other reason than to make my life over at the Clubhouse a bit more convenient. Frankly, I didn’t want to have to click through to watch YouTube and Google Videos.
It also makes no attempt to make a distinction between videos that you’d like to link to and videos that you’d like to embed. It embeds every YouTube or Google Video link it finds in a page. I guess if there’s a need or desire from anybody I can add that functionality – it would actually be pretty easy. But in the scope of its initial use there was no need to make this distinction.
The script also has no outside dependencies. I originally constructed it to use Prototype.js but I was only using one feature of Prototype.js (the each array iterator) so I decided to just add 3 lines of code to do the same thing. So now it stands alone which in the long run I think I prefer.
Less babble, more script!
Implementation is easy as the file takes care of everything. All you need to do it link to it in the head of your document like so:
And one more thing…
I forgot to mention when I originally posted this story that this script is intentionally incompatible with non-DOM aware browsers and with Internet Explorer.
It is incompatible with non-DOM aware browsers because I didn’t want to screw around with duplicating code to accommodate old browsers.
Edit: As of IE7’s release the setAttribute clause is still true. Why? Meh, IE sux.