2011-12-20 16:05:01 +04:00
|
|
|
/* Resize parent iframe to fit body
|
|
|
|
* License: Dual-license GPL 3.0+ or MPL 1.1+
|
|
|
|
* Contributor(s): Vitaliy Filippov <vitalif@mail.ru>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Allows to resize parent iframe to ease embedding Bugzilla pages
|
|
|
|
* onto pages from other domains. Sends HTML5 postMessage with text
|
2011-12-22 15:47:10 +04:00
|
|
|
* "resize(w=WIDTH;h=HEIGHT)" to parent window if loaded with ?_resize=1.
|
|
|
|
* Works in IE8+, FF 3+, Opera 9.5+, and Chrome.
|
2011-12-20 16:05:01 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
resizeParentIframe = function()
|
|
|
|
{
|
2011-12-22 15:47:10 +04:00
|
|
|
if ((/resize/.exec(window.location.hash) ||
|
|
|
|
/[&\?]_resize=1/.exec(window.location.href)) && 'postMessage' in parent)
|
2011-12-20 16:05:01 +04:00
|
|
|
{
|
|
|
|
var w = document.body.scrollWidth;
|
|
|
|
var h = document.body.scrollHeight;
|
|
|
|
parent.postMessage('resize(w='+w+';h='+h+')', '*');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (window.addEventListener)
|
|
|
|
window.addEventListener('load', resizeParentIframe, false);
|
|
|
|
else if (window.attachEvent)
|
|
|
|
window.attachEvent('onload', resizeParentIframe);
|