torsdag 29 september 2011

Tips #2 Add javascript: click() prototype to HTMLElement's for Firefox etc.

If you want to use the click() method on a HTML element on a webbrowser other than Microsoft's Internet Explorer you can add this code at the start somewhere of your code.

if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click)
    HTMLElement.prototype.click=function(){
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }


//QubeX2

Inga kommentarer: