May
29
Cool trick to extract only what you need using regular expressions
Filed Under JavaScript, PHP, Programming | Leave a Comment
I have a lot of article drafts sitting unused in my WP DB and I’ve decided to release them even though I don’t have very much time to get into details.
Here’s one of them.
I always comment the code I write like:
// Bogdan -> initializing dispatcher $this->dispatcher->init(); //-
Very often I’m required to extract the parts of the code I wrote, even though they are not full functions or classes, but just simple variables, or…
Read more
May
7
IE Object required error and other common coding mistakes
Filed Under JavaScript, Programming | Leave a Comment
Been having a lot of work on customizing Dokeos for a client, so didn’t really have any spare time to write.
This post is about common mistakes or overlooks when developing RIAs with JavaScript.
First of all, something to always keep in mind when working with Internet Explorer: it will never ever act like you wish from the first time.
Pay extra attention especially when dealing with DOM elements, as it tends to throw errors that FF doesn’t - I’m not talking about the fact that IE is not DOM compliant and methods that work in Mozilla family browsers don’t exist in IE or have different names.
Here’s a list of things to remember:
Read more
Apr
22
Simulating mouse clicks in JavaScript
Filed Under JavaScript, Programming | 7 Comments
There might
be times when you would like to simulate a mouse click on an DOM Node and don’t know how (for instance, submitting a form when in multi-frame environment).
Furthermore, it would be nice if the functionality could extend the DOM, so as to be able to use it combined with other pre-existing features.
Here’s the script bellow, just added and use it as you please (Ex. document.getElementById(”my_element”).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);
}
}