jquery get height of iframe content when loaded

ok I finally found a good solution: $(‘iframe’).load(function() { this.style.height = this.contentWindow.document.body.offsetHeight + ‘px’; }); Because some browsers (older Safari and Opera) report onload completed before CSS renders you need to set a micro Timeout and blank out and reassign the iframe’s src. $(‘iframe’).load(function() { setTimeout(iResize, 50); // Safari and Opera need a kick-start. var … Read more

javascript – document.write error?

document.write() is unstable if you use it after the document has finished being parsed and is closed. The behaviour is unpredictable cross-browser and you should not use it at all. Manipulate the DOM using innerHTML or createElement/createTextNode instead. From the Mozilla documentation: Writing to a document that has already loaded without calling document.open() will automatically … Read more

Difference between onload() and $.ready?

the load event (a.k.a “onload”) on the window and/or body element will fire once all the content of the page has been loaded — this includes all images, scripts, etc… everything. In contrast, jquery’s $(document).ready(…) function will use a browser-specific mechanism to ensure that your handler is called as soon as possible after the HTML/XML … Read more

AngularJS – Image “onload” event

Here’s a re-usable directive in the style of angular’s inbuilt event handling directives: angular.module(‘sbLoad’, []) .directive(‘sbLoad’, [‘$parse’, function ($parse) { return { restrict: ‘A’, link: function (scope, elem, attrs) { var fn = $parse(attrs.sbLoad); elem.on(‘load’, function (event) { scope.$apply(function() { fn(scope, { $event: event }); }); }); } }; }]); When the img load event … Read more