Javascript: Click outside element

Simply function to detect click event outside desired element: document.onclick = function (e) { e = e || event var target = || e.srcElement var element = document.getElementById(‘id_element’); do { if (element == target) { // When clicked inside element, does nothing return; } target = target.parentNode; } while (target) // When clicked outside […]

CSS3: target-new property

The target-new CSS property allows the target of a link to be set to a new window or new tab in the browser. It is equivalent to the target HTML attribute. It have three possible values window: opens in new window. tab: opens in new tabof browser (the most interesting usage). none. Example: div p […]

Javascript: get page dimensions (width and height)

In order to get the page height: document.body.scrollHeight; And in order to get the page width: document.body.scrollWidth; More comprehensive at Javascript Get Page Height With Scroll (Webdev Entry) Original article in spanish: Javascript: Halllar las dimensiones de la página (altura y anchura)

How to detect the Internet Explorer version in Javascript

It’s very easy: var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0; /*@cc_on opens the conditional, while @*/ closes it. The code inside conditional comment is only read by Internet Explorer. The code inside conditional comment establishes that […]