shindig の javascript

は、Java 版のバグなのか、PHP版のバグなのか、両方共通なのか、とかわからんがなと思いつつ、、ぶっちゃけshindigのプロジェクト自体がよく見えない & 見るつもりもあまりないので、メモ。

gadget.js という、ガジェットコンテナ用のJavaScript、微妙にiframeの取り扱いがよろしくないので修正。

しかし、iframe.location = xxx は1回目は素通りで、2回目以降(iframe src="xxx" が設定されて以降)だけ例外がthrowされるというのは(on Firefox 3)、想定外であった。。

iframe.location.href = "..." でいけるかなと思ったら、IEではOKだけれど、Firefox ではNGだった。知らんがなww

gadgets.Gadget.prototype.render = function(chrome) {
  if (chrome) {
    var gadget = this;
    this.getContent(function(content) {
      chrome.innerHTML = content;
      // original throws "setting a property that has only a getter" error
      // because frame.location gets readonly  after content is loaded.
      //
      // -- original
      // window.frames[gadget.getIframeId()].location = gadget.getIframeUrl();
      // -- fixed by yssk22
      document.getElementById(gadget.getIframeId()).src = gadget.getIframeUrl();
    });
  }
};