Étiquette : Programmation

Google Analytics : les recommandations de la CNIL [JavaScript]

La loi a changé concernant les cookies déposés chez les utilisateurs. Pour cela la CNIL a créé une page qui explique ce qu’il en est. Ils proposent même un bout de code pour le opt-in et le opt-out, que j’ai légèrement modifié : // Remplacez la valeur UA-XXXXXX-Y par l’identifiant analytics de votre site. var […]

Vérifier du code HTML en PHP

Supposons que vos utilisateurs peuvent entrer du code HTML et que vous souhaitiez vous assurer que les tags sont correctement fermés. Alors vous pouvez utiliser PHP pour faire ça : $codeUtilisateur = ‘<p><b>Mon texte</b>’; // il manque ‘</p>’ $doc = new DOMDocument(); // on utilise DOMDocument qui est installé par défaut avec PHP $doc->loadHTML($codeUtilisateur); $codeRetour […]

Sharepoint 2010 and IE in standard mode (issues with IE9/IE10)

I wanted to have a masterpage for Sharepoint 2010 with a HTML5 Doctype… unfortunately Sharepoint 2010 has been coded without standards, so lot of things are now broken. I spent some time to find the broken functions. I’ve created a file that is called just after <SharePoint:ScriptLink language= »javascript » name= »core.js » OnDemand= »true » runat= »server »/>, and you can download […]

gRaphaël pie chart animated to change the values [JavaScript]

I wanted to be able to change the values for a pie chart created with gRaphaël. After some tries I finally created a new method called changeValues that is available in my fork of gRaphaël. Below is an example: Move your mouse over one slice from the first chart to see the second one that […]

JavaScript APIs you’ve never heard of (And some you have)

From this video I’ve discovered several JS API I didn’t know. Let’s list them: 1) Use children instead of childNodes to list the children nodes of a DOM element: <ul> <li>Hello</li> <li>world</li> <li>!</li> </ul> <script> document.getElementById(‘test’).childNodes.length; // 7 -> because it also returns the text nodes document.getElementById(‘test’).children.length; // 3 </script> Support: all browsers, but from […]

Raphaëljs plugins for different charts [gRaphaël]

There is gRaphaël that provides several useful plugins to create some different charts like the pie charts, the line charts and so on, based on the Raphaël JS library. unfortunately, the owner doesn’t update his files very often, even if there are several pull requests from the users. So I decided to fork the main […]

How to trigger the window.resize event on IE8

For the modern browsers it’s easy to fire the window.resize event, but not for IE8…. After several hours of searching, I didn’t find anything. The only solution I found is the one to resize the HTML that will trigger the event: function triggerEvent(element, eventName) { var event; if (document.createEvent) { event = document.createEvent(« HTMLEvents »); event.initEvent(eventName, true, […]

WebPart doesn’t work with IE8 in standard mode under Sharepoint 2010

The Microsoft developers are not really good, and we can see it if you use IE8 in standard mode with Sharepoint 2010: the web parts don’t work anymore due to an error with the wpadder.js file. After few hours trying to find the problem I’ve finally discovered that the WPAdder class uses the for..in statement […]

Détection et polyfill pour émuler mouseenter et mouseleave [JavaScript]

Il semblerait qu’à l’heure où j’écris ces lignes, les événements « mouseenter » et « mouseleave » ne soient pas encore supportés par la dernière version stable de Chrome (alors que FF16 et IE les supportent). D’autres plus anciennes versions de Firefox peuvent aussi être impactées. Mais heureusement il existe un polyfill pour ça. Tout d’abord voici une fonction […]

Voir tout le code JavaScript présent dans une page [Astuce]

Il peut arriver qu’on ait besoin de voir tout le code JavaScript d’une page dans un unique endroit. Pour cela vous pouvez utiliser ce bout de code. Grâce à la partie « bookmarklet » vous pouvez créer un nouveau marque-page et utiliser le code fourni comme URL du marque-page. Ensuite il suffit d’aller sur la page voulue […]