Cross-Domain Scripting and XMLHttpRequest | In Conclusion
Overview
At VideoSift we have always made available the embed code for every video on the site. Until now, the provided code has just been the raw <object> and <embed> tags as you would acquire directly from the video host, but we wanted to provide a much more attractive embed.
We opted to achieve such a thing by providing users with a <script> tag that builds the fancy new widget into the DOM of the host page. Initially, the plan was to just generate a pretty simple DOM structure wrapped around a video, but it evolved from there to include:
- the ability to optionally start out as a thumbnail image that when clicked will expand into the full widget
- a functional vote button that would remotely cast an up-vote for logged in members
- a brief, scrollable listing of comments on the video
There were a few interesting issues that needed to be resolved along the way:
- Where on the host page should the widget be inserted?
- What happens if the host page contains multiple widget <script> tags?
- How should we dynamically load the widget in comments on VideoSift?
- How should we cast votes on remote host pages that need to be posted to VideoSift?