Embed Google Video and YouTube – Now bigger and better
Dec 14, 2006 | Web Design & Development | By Shawn Parker
Don't do this: the techniques used in this post and the sample pages use older techniques and don't account for modern browser safety precautions. Consider this a historical curiosity, like a circus freak show…
Well, technically smaller. This new version actually has less lines of code. See, I was trying to be a good boy when I first wrote the script. I tried to be fully DOM compliant and not use innerHTML as it is a non-standard function and has somewhat of a dubious reputation.
Well. Screw it. IE will do the DOM standard element replacement, but doesn’t do setAttribute. Opera would take the DOM replacement and make space for it in the layout but wouldn’t show the video element. All this goes away with innerHTML.
Please take a look at the new sample page (the old one is still available through the old article). If you could leave a note in the comments about your experiences with your particular browser I’d appreciate it, but I’m pretty sure that IE 6 is my only real concern. I’m not going to target IE 5.5 on Mac or PC.
You can view the source (embed_yt_gv.js) and please feel free to use it. If you do, as always, just drop me an email or a comment here to let me see where you’re using it.