Un très excellent code d'effet, vous pouvez faire défiler de haut en bas, à gauche et à droite, et vous l'avez collecté! !
<! Doctype html public "- // w3c // dtd xhtml 1.0 strict // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"><html xmlns = "http://www.w3.org/1999/xhtml"> <éadf> <meta http-equiv = "contenu-type" contenu = "Text / html; Charset = gb2312" /> <itle> Scrolling Test </ title> <script type = "text / javascrip "Demo" dans Demo, Deml1, Demo2 peut être arbitrairement tant qu'il n'est pas répété * * @para vitesse Plus la vitesse de défilement est grande, plus la direction * * @para est la direction visible totale de la largeur * obtenu automatiquement pour faire défiler l'image dans le dossier) * * @Para ContentByid faites défiler le contenu avec un certain ID ContentByid Ce défilement et FilePath ne peuvent pas coexister. Veuillez noter * * @para instance d'utilisation ScrolloBject ("RES", 50, "UP", 470,200, "", "Resource") Faites défiler le contenu sous ContentyId (Resource) * * @Para USAGE Instance ScrolloBject ("Res", 50, "Up", 470,200, "d: // images //", "") Obtenir automatiquement et scroll le contenu sous Frépath (images). Actuellement, uniquement IE * / var $ = fonction (id) {return document.getElementById (id)} // Scroll Fonction ScrolLobject (obj, vitesse, direction, objwidth, objHeight, filepath, contentbyid) {// exécuter l'initialisation if (direction == "up" || direction == "down") document.write (udStructure ()); else document.write (lrStructure ()); Var Demo = $ (obj); var Demo1 = $ (obj + "1"); var Demo2 = $ (obj + "2"); Var Speed = Speed; $ (contentByid) .style.display = "None" Demo.style.overflow = "Hidden"; Demo.style.width = objwidth + "px"; Demo.style.Height = ObjHeight + "PX"; Demo.Style.Margin = "0 Auto"; if (filepath! = "") Demo1.innerHtml = file (); if (contentById! = "") Demo1.InnerHtml = $ (contentById) .InnerHTML; Demo2.InnerHtml = Demo1.InnerHtml; // défile la fonction gauche et droite lrstructure () {var _html = ""; _html + = "<div id = '" + obj + "'>"; _html + = "<Table Border = '0' Align = 'Left' CellPadding = '0' CellSpace = '0' CellSpace = '0'>"; _html + = "<tr>"; _html + = "<td nowrap = 'nowrap' id = '" + obj + "1'>"; // Voici le contenu à défiler_html + = "</td>"; _html + = "<td nowrap = 'nowrap' id = '" + obj + "2'> </td>"; _html + = "</tr>"; _html + = "</tr>"; _html + = "</ table>"; _html + = "</div>"; retour _html; } // défilement de la fonction de structure de haut en bas uDstructure () {var _html = ""; _html + = "<div id =" + obj + ">"; _html + = "<Table Border = '0' Align = 'Left' CellPadding = '0' CellSpace = '0'>"; _html + = "<tr>"; _html + = "<td id = '" + obj + "1'>"; // Voici le contenu à défiler_html + = "</td>"; _html + = "<tr>"; _html + = "<tr>"; _html + = "<td id = '" + obj + "1'>"; // Voici le contenu à défiler_html + = "</td>"; _html + = "<tr>"; _html + = "<tr>"; _html + = "<td id = '" + obj + "2'> </td>"; _html + = "</tr>"; _html + = "</ table>"; _html + = "</div>"; retour _html; } // Obtenez le fichier de fonction de l'image () {var tbsource = filepath; // chemin de dossier local filepath = filepath.toString (); if (filepath == "") return ""; var imglist = ""; var objfso = new activeXObject ('scripting.filesystemObject'); // si le dossier existe if (! Objfso.folderexists (tbsource)) {alert ("<" + tbsource + "> Le chemin du dossier n'existe pas, ou le chemin ne peut pas contenir de nom de fichier!"); objfso = null; retour; } var objfolder = objfso.getfolder (tbsource); var colFiles = nouveau énumerateur (objfolder.files); var re_inf1 = //. jpg $ /; // Vérifiez si le fichier de dossier est un fichier jpg pour (;! ColFiles.Atend (); colFiles.MoVeNExt ()) // Lisez le fichier dans le dossier {var objfile = ColFiles.item (); if (re_inf1.test (objfile.name.tolowercase ())) {imglist + = "<img src =" + filepath + "/" + objfile.name + ">"; }} return imglist; } // Scroll Fonction gauche gauche () {if (demo2.offsetwidth-demo.scrollleft <= 0) {demo.scrollleft- = DEMO1.offsetWidth; } else {Demo.Scrollleft ++; }} // Scroll Right Fonction droite () {if (Demo.ScrolLleft <= 0) {Demo.Scrollleft- = Demo1.offsetWidth; } else {Demo.Scrollleft ++; }} // Scroll Right Fonction droite () {if (Demo.Scrollleft <= 0) {Demo.Scrollleft + = Demo2.offsetWidth; } else {Demo.Scrollleft--}} // Scroll Down Function Down () {if (Demo1.offSetTop-Demo.ScrollTop> = 0) {Demo.ScrollTop + = Demo2.OffSetHeight; } else {Demo.ScrollTop--}} // Scroll Up Function Up () {if (Demo2.offSetTOP-Demo.ScrollTop <= 0) {Demo.ScrollTop- = Demo1.offsetHeight; } else {Demo.ScrollTop ++}} // Fonction de direction de commutation swichDirection () {switch (direction) {case "Left": return Left (); casser; cas "droit": retour droit (); casser; cas "up": return up (); casser; par défaut: return down (); }} // répéter var myMarquee = setInterval (swichDirection, Speed); // Hover Over Demo.OnMouseOver = function () {ClearInterval (MyMarquee);} // Décrochez à nouveau défiler Demo.OnMouseout = Function () {MyMarquee = SetInterval (SwichDirection, Speed);}} </ Script> </ Head> <body> <div id = "IMG"> <Tableau = "Centre" Centre "Centre =" 5 " Cellpacing = "0"> <tr> <td> <img src = "http://attach.e.iciba.com/attachment/200910/22/4188617_12561994098532.jpg" /> </ td> <td> <img src = "http://pica.nipic.com/2008-05-27/2008527145211519_2.jpg" /> </td> <td> <img src = "http://pic4.nipic.com/20090823/383152_215728074589_2.jpg" /> </ td> <td> <img src = "http://pic8.nipic.com/20100628/4643449_170245009531_2.jpg" /> </ td> <td> <img src = "http://pica.nipic.com/2008-05-30/20085309524648_2.jpg" /> </td> </tr> </ table> </div> <script Type = "Text / JavaScript"> ScrolLobject ("SR", 50, "Right", 800,160, "", "IMG") </cript> </ body> </html>Ce qui précède est l'intégralité du contenu de cet article. Pour plus d'informations sur JavaScript, vous pouvez consulter: "JavaScript Reference Tutorial" et "JavaScript Code Style Guide". J'espère également que tout le monde soutiendra davantage Wulin.com.