<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://prendreuncafe.com/blog/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Prendre un Café - scriptaculous</title>
  <link>http://prendreuncafe.com/blog/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Fri, 18 Jul 2008 22:47:12 +0200</pubDate>
  <copyright>Contenus sous licence Creative Commons BY-SA</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Effets javascript avec Prototype et Scriptaculous</title>
    <link>http://prendreuncafe.com/blog/post/2006/03/19/410-effets-javascript-avec-prototype-et-scriptaculous</link>
    <guid isPermaLink="false">urn:md5:355ff902cfb1e787272138ff44918ab1</guid>
    <pubDate>Sun, 19 Mar 2006 13:19:21 +0000</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>dev</category><category>effets</category><category>javascript</category><category>prototype</category><category>scriptaculous</category><category>tutoriel</category><category>web</category>    
    <description>&lt;p&gt;On a vu fleurir moult trolls velus à propos du web 2.0 et sa débauche d'&lt;acronym title=&quot;Asynchronous JavaScript + XML&quot;&gt;AJAX&lt;/acronym&gt; et de javaScript inaccessibles, je ne les nourrirai pas ici. Par contre et pour ceux que ça interesse, les librairies &lt;a href=&quot;http://prototype.conio.net/&quot; hreflang=&quot;en&quot;&gt;prototype&lt;/a&gt; et &lt;a href=&quot;http://script.aculo.us/&quot; hreflang=&quot;en&quot;&gt;script.aculo.us&lt;/a&gt; proposent des outils et effets très sympathiques. Voici quelques exemples très simples d'utilisation.&lt;/p&gt;    &lt;h3&gt;Installation&lt;/h3&gt;


&lt;p&gt;Le plus simple est de récupérer la &lt;a href=&quot;http://script.aculo.us/downloads&quot; hreflang=&quot;en&quot;&gt;dernière version de scriptaculous&lt;/a&gt; qui contient elle même une version toujours récente de prototype. Ceci fait, decompactez l'archive et copiez les librairies dans un répertoires de votre serveur web. Pour ma part, je mets tout ça dans un répertoire &lt;code&gt;js&lt;/code&gt;. Il ne reste qu'à les appeller dans l'entête de votre document &lt;acronym title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/acronym&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;html&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;head&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;title&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Mon test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/title&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;js/prototype.js&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/script&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;js/scriptaculous.js&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/script&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/head&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  ...&lt;/pre&gt;


&lt;h3&gt;Utilisation&lt;/h3&gt;


&lt;p&gt;Réalisons un petit document &lt;acronym title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/acronym&gt; pour commencer à utiliser quelques effets &lt;em&gt;scriptaculaires&lt;/em&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;html&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;head&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;title&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Mon test&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/title&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;js/prototype.js&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/script&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;src&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;js/scriptaculous.js&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/script&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/head&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;body&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;h1&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Lorem ipsum dolor sit amet&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/h1&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;p&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;mytext&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;style&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;display:none&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut 
    fringilla arcu at turpis. Fusce libero. Morbi libero dolor, 
    vestibulum id, facilisis quis, malesuada vel, mi. Curabitur 
    rutrum sapien at ante. Sed consectetuer accumsan sapien. 
    Suspendisse scelerisque malesuada magna. Ut laoreet, sapien 
    facilisis venenatis pharetra, metus libero malesuada purus, id 
    ultrices dolor odio id nunc. Nullam vestibulum. Vivamus lectus 
    lacus, volutpat ut, varius sit amet, gravida at, nisi. 
    Suspendisse sodales auctor mi. Mauris est.&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/p&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/body&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/html&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Vous noterez que ce document fort simple n'affiche pour l'instant que le titre du document - nanti d'un lien hypertexte vide - du fait du style &lt;code&gt;display:none&lt;/code&gt; appliqué au paragraphe principal. Pour que le texte de l'article apparaisse en fondu lors d'un clic sur le titre, il suffit d'utiliser ce simple appel javascript sur le lien de la balise de titre&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;h1&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Appear('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Lorem ipsum dolor sit amet&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/h1&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;Magique non&amp;nbsp;? Simple, assurément.&lt;/strong&gt; La méthode &lt;code&gt;Appear()&lt;/code&gt; de l'objet &lt;code&gt;Effect&lt;/code&gt; accèpte deux arguments&amp;nbsp;: le premier est l'identifiant unique de l'objet &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt; de la page courante (dans notre exemple, l'id &lt;code&gt;mytext&lt;/code&gt; est attribué à notre paragraphe). Le second paramètre est la durée en secondes de l'effet. Amusez-vous à en modifier la valeur et à tester le résultat.&lt;/p&gt;


&lt;p&gt;De la même manière, vous pouvez appliquer d'autres effets à ce pauvre bloc de texte&amp;nbsp;; pour en tester une grande partie, ajoutez cette portion de code à notre page de test&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;p&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.BlindDown('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;BlindDown&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.BlindUp('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;BlindUp&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Highlight('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Highlight&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Grow('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Grow&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Shrink('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Shrink&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Squish('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Squish&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.SwitchOff('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;SwitchOff&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Shake('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Shake&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Pulsate('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Pulsate&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Fold('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Fold&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.DropOut('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;DropOut&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; |
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;button&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Reset&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Appear('mytext', 1)&quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/p&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Voila une page vous permettant de tester les exemples&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://prendreuncafe.com/blog/share/scriptaculous-test/effects.html&quot; hreflang=&quot;fr&quot;&gt;Page de démonstration des différents effets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Notez également la possibilité d'utiliser un méthode de &lt;em&gt;scrolling doux&lt;/em&gt; lors de la navigation au sein d'une même page grâce à l'utilisation d'ancres nommées, et ce grâce à l'effet &lt;code&gt;ScrollTo&lt;/code&gt;&amp;nbsp;: encore une fois, un exemple vaut mieux qu'un long discours&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://prendreuncafe.com/blog/share/scriptaculous-test/scrollto.html&quot; hreflang=&quot;fr&quot;&gt;Exemple de scrolling fluide entre ancres nommées&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;La syntaxe de l'appel à cette fonction est extrêmement simple&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;#nav1&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.ScrollTo('nav1',{duration:1});return false;&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Lorem ipsum dolor sit amet&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Vous l'aurez compris, il faut passer en premier argument l'id &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt; que vous ciblez (qui fera office d&lt;em&gt;'ancre nommée&lt;/em&gt;), et en second paramètre la durée du défilement.&lt;/p&gt;


&lt;p&gt;Vous trouverez sur le wiki officiel de la librairie une &lt;a href=&quot;http://wiki.script.aculo.us/scriptaculous/show/CombinationEffectsDemo&quot; hreflang=&quot;en&quot;&gt;liste complète d'exemples&lt;/a&gt; d'utilisation des effets combinés.&lt;/p&gt;


&lt;h3&gt;Et l'accessibilité dans tout ça&amp;nbsp;?&lt;/h3&gt;


&lt;p&gt;L'influence de l'utilisation d'effets javascript sur l'accessibilité &lt;strong&gt;n'est que de votre ressort&lt;/strong&gt;. Dans notre exemple précédent, la page est potentiellement inaccessible puisque notre paragraphe &lt;code&gt;mytext&lt;/code&gt; possède un attribut de style &lt;code&gt;display:none&lt;/code&gt;, non lu par quelques lecteurs d'écran du marché. Qu'à cela ne tienne, il nous faut impérativement gérer le contenu de l'attribut &lt;code&gt;href&lt;/code&gt; de nos balises de liens utilisant javascript, de manière à ce que &lt;strong&gt;javascript ne soit pas nécessaire à la consultation des informations&lt;/strong&gt; et qu'un clic sur le lien nous amène à une page affichant le contenu de notre paragraphe. Par exemple, on pourrait imaginer&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;afficher_article.php?full=1&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Appear('mytext', 1)&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Test d'accessibilit&lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;eacute;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Parfait, notre lien est cliquable et nous redirige vers une autre page. Ah oui, mais nous avons un problème&amp;nbsp;: du coup ce lien prend la main sur notre effet javascript... Qu'à cela ne tienne, le problème est résolu en renvoyant la valeur &lt;code&gt;false&lt;/code&gt; lors de l'execution de l'action clic sur le lien&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;href&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;afficher_article.php?full=1&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;onclick&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;new Effect.Appear('mytext', 1);return false&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Test d'accessibilit&lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;eacute;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/a&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;&lt;acronym title=&quot;Asynchronous JavaScript + XML&quot;&gt;AJAX&lt;/acronym&gt; rend vos pages plus brillantes&lt;/h3&gt;


&lt;p&gt;Prototype et Scriptaculous proposent des outils qui vous simplifient la vie pour faire de l'&lt;acronym title=&quot;Asynchronous JavaScript + XML&quot;&gt;AJAX&lt;/acronym&gt;. Par exemple, la fameuse autocompletion du champ recherche relève du jeu d'enfant. Imaginons que vous souhaitiez proposer l'autocompletion d'un champ de formulaire pour le choix d'un prénom. Voici le formulaire de base&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;action&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;method&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Quel est votre pr&lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;eacute;&lt;/span&gt;nom ?&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/label&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;size&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;30&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/form&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Scriptaculous propose un objet &lt;code&gt;Ajax&lt;/code&gt; très pratique et disposant nativement d'une méthode &lt;code&gt;Updater()&lt;/code&gt; permettant de s'acquitter de la tâche qui nous interesse. Voici le code final&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;action&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;method&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;label&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;for&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Quel est votre pr&lt;span style=&quot;color: #ddbb00;&quot;&gt;&amp;amp;eacute;&lt;/span&gt;nom ?&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/label&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;size&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;30&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prenom&quot;&lt;/span&gt; &lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prn_update&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/div&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/form&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
new Ajax.Autocompleter (
  'prenom',      // ID of the source field
  'prn_update',  // ID of the DOM element to update
  'prenoms.php', // Remote script URI
  {method: 'post', paramName: 'prenom'}
);
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/script&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Je pense que le code parle de lui-même, mais au cas où cela ne soit pas clair pour tout le monde, détaillons ensemble les différents éléments&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;prn_update&quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/div&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cet élément sera le &lt;em&gt;receptacle&lt;/em&gt; de nos appels asynchrones au script &lt;code&gt;prenoms.php&lt;/code&gt;&amp;nbsp;; c'est dans cet élément que seront inscrites les informations reçues, en l'occurence ici la liste des prénoms correspondants aux lettres saisies dans l'élément de formulaire &lt;code&gt;prenom&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;new&lt;/span&gt; Ajax.&lt;span style=&quot;color: #006600;&quot;&gt;Autocompleter&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
  &lt;span style=&quot;color: #3366CC;&quot;&gt;'prenom'&lt;/span&gt;,      &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// ID of the source field&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le premier argument de notre objet sera l'identifiant &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt; du champ de formulaire à qui l'on destine l'autocompletion.&lt;/p&gt;

&lt;pre&gt;  &lt;span style=&quot;color: #3366CC;&quot;&gt;'prn_update'&lt;/span&gt;,  &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// ID of the DOM element to update&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ce deuxième argument est l'identifiant &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt; du receptacle des informations reçues.&lt;/p&gt;

&lt;pre&gt;  &lt;span style=&quot;color: #3366CC;&quot;&gt;'prenoms.php'&lt;/span&gt;, &lt;span style=&quot;color: #009900; font-style: italic;&quot;&gt;// Remote script URI&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le troisième argument n'est autre que l'&lt;acronym title=&quot;Universal Resource Identifier&quot;&gt;URI&lt;/acronym&gt; du script qui nous fournira nos données. A titre d'exemple, pour notre liste de prénoms, le script &lt;acronym title=&quot;PHP: Hypertext Preprocessor&quot;&gt;PHP&lt;/acronym&gt; pourrait être&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;$p&lt;/span&gt; = &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Aaron&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Abdallah&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Abdel&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Vous pouvez completer cette liste a votre guise...&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Yvon&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Zoubida&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Zouhir&quot;&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;Zorobabel&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #0000ff;&quot;&gt;$q&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'prenom'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;; &lt;span style=&quot;color: #0000ff;&quot;&gt;$i&lt;/span&gt; = &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$q&lt;/span&gt; != &lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;ul&amp;gt;'&lt;/span&gt;;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;foreach&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$p&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$prn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/substr&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;substr&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/strtolower&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strtolower&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$prn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,&lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;,&lt;a href=&quot;http://www.php.net/strlen&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strlen&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$q&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; == &lt;a href=&quot;http://www.php.net/strtolower&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;strtolower&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/stripslashes&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;stripslashes&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$q&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#&amp;quot; onclick=&amp;quot;return false&amp;quot;&amp;gt;'&lt;/span&gt;.htmlentities&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$prn&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;'&lt;/span&gt;;
      &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;++&lt;span style=&quot;color: #0000ff;&quot;&gt;$i&lt;/span&gt; &amp;gt;= &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;a href=&quot;http://www.php.net/die&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;die&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;li&amp;gt;...&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;/ul&amp;gt;'&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Enfin, le quatrième argument de notre objet &lt;code&gt;Ajax.Updater&lt;/code&gt; est un objet javascript de paramétrage de la requête&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;method: &lt;span style=&quot;color: #3366CC;&quot;&gt;'post'&lt;/span&gt;, paramName: &lt;span style=&quot;color: #3366CC;&quot;&gt;'prenom'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;La propriété &lt;code&gt;method&lt;/code&gt; spécifie la méthode &lt;acronym title=&quot;HyperText Transfer Protocol&quot;&gt;HTTP&lt;/acronym&gt; que vous souhaitez utiliser pour interroger votre script (dans notre cas, &lt;code&gt;post&lt;/code&gt;) et &lt;code&gt;paramName&lt;/code&gt; déclare le nom de la variable à passer au script pour l'interrogation&amp;nbsp;; dans notre cas nous passons &lt;code&gt;prenom&lt;/code&gt; qui sera ainsi correctement interprétée et traitée par notre script PHP en utilisant &lt;code&gt;$_POST['prenom']&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Bien évidemment, il est possible de grandement améliorer l'esthétique du menu généré grâce à l'utilisation de règles &lt;acronym title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/acronym&gt; appropriées. Par exemple&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;  #prn_update &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;border&lt;/span&gt;: 1px &lt;span style=&quot;color: #993333;&quot;&gt;solid&lt;/span&gt; #999;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;: #fafafa;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
  #prn_update ul &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;margin&lt;/span&gt;: &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;: &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;list-style&lt;/span&gt;: &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
  #prn_update a &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;display&lt;/span&gt;: &lt;span style=&quot;color: #993333;&quot;&gt;block&lt;/span&gt;;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;padding&lt;/span&gt;: &lt;span style=&quot;color: #6666ff;&quot;&gt;.2em &lt;/span&gt;.3em;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;text-decoration&lt;/span&gt;: &lt;span style=&quot;color: #993333;&quot;&gt;none&lt;/span&gt;;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;color&lt;/span&gt;: #333;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #6666ff;&quot;&gt;.selected &lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;background&lt;/span&gt;: lightyellow;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Enfin, voila un lien vers l'exemple en live&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://prendreuncafe.com/blog/share/scriptaculous-test/autocomplete.html&quot; hreflang=&quot;fr&quot;&gt;Test de l'autocompletion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Conclusion&lt;/h3&gt;


&lt;p&gt;Nous avons à peine survolé un dixième des capacités de ces librairies au potentiel pour le moins énorme. Et comme vous avez pu le constater, la facilité de mise en place et d'utilisation sont au rendez-vous, les résultats spéctaculaires et améliorant de façon significative la navigation et la consultation des informations.&lt;/p&gt;


&lt;p&gt;Attention toutefois à ne pas surcharger vos pages d'effets et veillez toujours à ce que ces derniers restent au service de l'efficacité et de l'utilisabilité de vos interfaces, en n'oubliant jamais de garder les problématiques d'accessibilité à l'esprit &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>