微妙にメモリーリーク・パターンになって・・・

外部HTMLの特定のクラス名の文のみとりだしたい
http://oshiete.goo.ne.jp/qa/8548024.html

bind で囲った時点で、OKなのか?暇なときに調べる、だれかが。
removeEventListener でイベントを取り除くとき、 Function.bind () のように同じにしなきゃないとか?

走査が終了した時点で、 iframe は、取り除け。

<!DOCTYPE html>
<meta charset="utf-8">
<title>IFRAME SCANNING</title>
<body>
<script>

function fuga () {
  var doc = this.contentDocument;
  var es = doc.getElementsByClassName ('en');
  var text = Array.prototype.map.call (es, getTextContent);
  
  alert (text.join ('\n'));
  
  this.removeEventListener ('load', fuga.bind (this), false); //←果たして同じものなのか?
  this.parentNode.removeChild (this); 
}


function getTextContent (e) {
  return e.textContent;
}


function hoge (url, cbFunc) {
  var iframe = document.createElement ('iframe');
  
  iframe.src = url;
  iframe.style.display = 'none';
  iframe.addEventListener ('load', cbFunc.bind (iframe), false);
  
  document.body.appendChild (iframe);
  iframe = null;
}

//----

hoge ('test.html', fuga);


</script>

PHPが動くなら

readfile();