
Pywebkitgtk – execute Javascript from python
Last week I’ve got a new assignment at my job: a crawler that was supposed to periodically visit some sites and download their content. Sounds simple, isn’t it? Well, it’s not. Mainly because we want to also get all the flash content and some of it is inserted with Javascript, via various libraries like SWFobject […]
Lunascape web browser
‘Few days ago, I’ve received this link from Siderite. It’s about a new browser, called Lunascape. My first question is: do we really need another browser? Don’t we have enough browsers already? According to their website, Lunascape is a triple engine web-browser, with implementations of Trident (Microsoft), Gecko (Firefox) and WebKit (Safari). This could be […]
Element.prototype in IE
Some time ago, I needed to find out if a DOM element is a descendant of another. A simple and elegant way to accomplish this is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/** * * @param mixed granpa * */ Element.prototype.isDescendantOf = function( granpa ) { if ( typeof( granpa ) == 'string' ) { granpa = document.getElementById( granpa ); } if ( !granpa ) { return false; } child = this; do { if (child == granpa ) { return true; } child = child.parentNode; } while ( child ); return false; } |
…and afterwards…
1 2 3 4 5 |
var foo = document.getElementById( 'foo' ); var bar = document.getElementById( 'bar' ); if ( foo.isDescendantOf( bar ) ) { /* whatever */ } |
Cool, isn’t it?
Most commented