SoFunction
Updated on 2025-03-01

Simple example of Javascript implementing marquee effect

Page html:

<div>
            <div  runat="server" style="padding-bottom: 10px;">
              <div  style="overflow: hidden; width: 100%; height: 190px">
                <table cellspacing="0" cellpadding="0" align="left" border="0" cellspace="0">
                  <tr>
                    <td  valign="top" runat="server">
                    </td>
                    <td  valign="top">
                    </td>
                  </tr>
                </table>
              </div>
              <script type="text/javascript">
                var speed = 10
                var demo = ("demo");
                var demo1 = ("demo1");
                var demo2 = ("demo2");
                 = 
                function Marquee() {
                  if ( -  <= 0)
                     -= 
                  else {
                    ++
                  }
                }
                var MyMar = setInterval(Marquee, speed)
                 = function () { clearInterval(MyMar) }
                 = function () { MyMar = setInterval(Marquee, speed) } 
              </script>
            </div>
          </div>

CS background code:

private void BindPics(int comId)
  {
    List<> pic = (comId);
    StringBuilder sb = new StringBuilder();
    if (pic == null ||  < 1)
    {
       = ;
      return;
    }
    ("<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\"cellspacing=\"10px\"><tr>");
    for (int i = 0; i < ; i++)
    {
       p = pic[i];
      (" <td width=\"200\"><a href=\"" +  + "\"><img src=\"../" +  + "\" border='0' title=\"" +  + "\" alt=\"" +  + "\"></a></td>");
    }
    ("</tr></table>");
     = ();
  }

Database table:

USE [Enterprise]
GO
/****** Object: Table [dbo].[Pics] Script Date: 03/17/2011 19:26:27 *******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Pics](
 [Id] [int] IDENTITY(1,1) NOT NULL,
 [ComId] [int] NOT NULL,
 [Title] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL,
 [Href] [varchar](255) COLLATE Chinese_PRC_CI_AS NULL,
 [Src] [varchar](255) COLLATE Chinese_PRC_CI_AS NOT NULL,
PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Entity Class:

public class Pic
  {
    public int Id { set; get; }
    public int ComId { set; get; }
    public  CompanyModel { set; get; }
    public string Title { set; get; }
    public string Src { set; get; }
    public string Href { set; get; }
  }

The above simple example of Javascript's marquee effect is all the content I share with you. I hope you can give you a reference and I hope you can support me more.