Mootools load local files similar to Jquery

Monday of May 28, 2012

I encountered a problem in loading local html files in mootools, but this feature is managed in jquery. I checked the implementation and mootools can implement the similar behavior based on the following sets of codes below.

function get_content(url,callback) { var str = ''; var f = new IFrame({ src:url, styles:{display:'none'}, events:{ load: function() { var d = new Element('div'); d.adopt(this.contentWindow.document.body); var ds = new Elements([d]); ds.each(function(el){ str+=(el.getElement('body').get('html')); }); f.dispose(); callback(str); } } }).inject(document.body); } get_content('test.html',function(str){ $('target-dom').set('html',str);});