Skip to content

Instantly share code, notes, and snippets.

@fregante
Created March 18, 2012 17:19
Show Gist options
  • Save fregante/2077913 to your computer and use it in GitHub Desktop.
Save fregante/2077913 to your computer and use it in GitHub Desktop.
Get popup player from any embedded Flash video
//Click on the closest parent element of a video to have it popped out and the main window closed
(function (css, int, d, s) {
d.body.appendChild(s = document.createElement('style'));
s.innerHTML = ':hover{border-left:3px solid papayawhip;}';
d.body.onclick = function (e) {
var popd,
v = e.srcElement.querySelectorAll('embed,object,iframe')[0] || d.querySelectorAll('embed,object,iframe')[0],
w = int(css(v).width) || 400,
h = int(css(v).height) || 300,
pop = window.open(d.location.href,''+Math.random(),'height='+h+',width='+w),
t = setInterval(function () {
popd = pop.document;
if( popd.getElementsByTagName('title').length ) {
clearInterval(t);
//popd.write(0);
var el = popd.createElement('body');
el.innerHTML = '<style>* {margin:0 !important;padding:0 !important;height:100% !important}</style>'+v.outerHTML;
popd.documentElement.removeChild(pop.document.body);
popd.documentElement.removeChild(pop.document.head);
popd.documentElement.appendChild(el);
window.close();
}
}, 300);
window.pop = pop;
}
}(window.getComputedStyle,parseInt,document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment