-
Notifications
You must be signed in to change notification settings - Fork 1
/
iframe-responsive.min.js
5 lines (5 loc) · 1.47 KB
/
iframe-responsive.min.js
1
2
3
4
5
/*
iFrameResponsive.js
by Lackneets Chang < [email protected] >
*/
!function(){function t(t){try{return JSON.parse(t)&&!0}catch(e){return!1}}function e(t){for(var e=[],o=t.length>>>0;o--;)e[o]=t[o];return e}function o(t,e,o){t.addEventListener?t.addEventListener(e,o,!1):t.attachEvent&&t.attachEvent("on"+e,o)}Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var o,n=this,r=n.length,a=e?e:void 0;for(o=0;r>o;o+=1)n.hasOwnProperty(o)&&t.call(a,n[o],o,n)}),CSSStyleDeclaration.prototype.setProperty||(CSSStyleDeclaration.prototype.getProperty=function(t){return this.getAttribute(t)},CSSStyleDeclaration.prototype.setProperty=function(t,e){return this.setAttribute(t,e)},CSSStyleDeclaration.prototype.removeProperty=function(t){return this.removeAttribute(t)});var n=function(t){"complete"==document.readyState?t():document.addEventListener?window.addEventListener("load",t,!1):window.attachEvent("onload",t)};n(function(){function n(o){var n=t(o.data)?JSON.parse(o.data):o.data;n.location&&e(document.getElementsByTagName("iframe")).forEach(function(t){n.location==t.src&&(t.style.setProperty("height",n.height+"px","important"),a.push(t))})}function r(){parent.postMessage(JSON.stringify({height:document.body.offsetHeight,location:window.location.toString()}),"*")}var a=[];o(window,"message",n),window.parent!=window&&window.parent.postMessage&&(document.body.style.overflowY="hidden",o(window,"resize",r),o(window,"load",r),setTimeout(r,100),setTimeout(r,300),setTimeout(r,600))})}();