All pastes #48469 Raw Edit

Something

public text v1 · immutable
#48469 ·published 2006-04-07 02:00 UTC
rendered paste body
/* jir.js
 * requires behaviour.js
 * html looks like: <hX class="jir_replace" id="mytitle.jpg">My Title</hX>
 * requires an empty.gif to make sure IR should even happen (imagse are turned on)
 * this gif can be 1px by 1px with 1 color pallette
 */
var test = new Image();
var tmp = new Date();
test.src = 'empty.gif?'+tmp.getTime();
test.onload = registerReplacement;

function registerReplacement() {
  Behaviour.register( {
    '.jir_replace' : function(el) {
      if(el.id) {
        var ir = document.createElement('img');
        ir.src = el.id;
        ir.alt = el.firstChild.nodeValue;
        el.replaceChild(ir, el.firstChild);
      }
    }
  });
}