Month: March 2015

Détecter la version d’IE [JavaScript]

Via http://tanalin.com/en/articles/ie-version-js/ on trouve un moyen simple de détecter la version d’IE : var IE8 = !!(document.all && document.querySelector && !document.addEventListener); // -> true/false var IE9 = !!(document.all && document.addEventListener && !window.atob); // -> true/false var IE10 = !!(document.all && window.atob); // -> true/false On peut aussi utiliser les conditionals compilation: var ieVersion = /*@cc_on […]

Get window/viewport/document height and width [JavaScript]

Via andylangton and james.padolsey we can find the viewport and document height/width in JavaScript: function getPageSize() { var vw = {width:0, height:0}; var doc = {width:0, height:0}; var w=window, d=document, dde=d.documentElement, db=d.getElementsByTagName(‘body’)[0]; // viewport size vw.width = w.innerWidth||dde.clientWidth||db.clientWidth; vw.height = w.innerHeight||dde.clientHeight||db.clientHeight; // document size doc.width = Math.max(db.scrollWidth, dde.scrollWidth, db.offsetWidth, dde.offsetWidth, db.clientWidth, dde.clientWidth); doc.height = Math.max(db.scrollHeight, […]

Autosize a text to fit into a div in pure/native JavaScript

I was looking for a very tiny and light solution to fit a text inside a box. The box’ height and width are fixed. I only found some great solutions like BigText but I didn’t want to have jQuery loaded. Finally I found some code on StackOverflow and also at Coderwall. I created my own […]

Ajouter “nocaptcha reCaptcha” de Google à Guiform sous WordPress [Astuce]

J’utilise GuiForm pour faire des formulaires dans un WordPress, et je voulais y ajouter le captcha de Google sans pour autant devoir payer la licence chère de GuiForm juste pour ça… Pour réussir ce que je décris ci-dessous, il vous faudra connaitre votre clé privée et publique de Google Captcha. Il faut commencer par faire […]

Activer la compression gzip / deflate sur 1and1 [Astuce]

Ayant un WordPress chez 1and1 j’ai voulu activer la compression de mes pages. Après avoir longuement cherché de partout, j’ai trouvé comment procéder, et ce n’est vraiment pas simple…. En effet, il va falloir faire passer tous nos fichiers (js, css, html, …) par PHP afin qu’ils soient compressés à la volée. Chemin d’accès complet […]