A simple example _javascript technique for realizing the effect of the Happy lantern in JavaScript

Source: Internet
Author: User
Tags setinterval

Page HTML:

<div> <div id= "imgshows" runat= "Server" style= "padding-bottom:10px;" > <div id= "demo" style= "Overflow:hidden; width:100%;
                  height:190px "> <table cellspacing=" 0 "cellpadding=" 0 "align=" left "border=" 0 "cellspace=" 0 "> <tr> <td id= "Demo1" valign= "Top" runat= "Server" > </t 
                d> <td id= "Demo2" valign= "Top" > </td> </tr>
                </table> </div> <script type= "Text/javascript" >
                var speed = Ten var demo = document.getElementById ("demo");
                var demo1 = document.getElementById ("Demo1");
                var Demo2 = document.getElementById ("Demo2"); demo2.innerhtml = demo1.innerhtml function Marquee () {if (Demo2.offsetwidth-demo.scro LlleFT <= 0) demo.scrollleft-= Demo1.offsetwidth else {DEMO.SCR ollleft++}} var MyMar = SetInterval (Marquee, Speed) de Mo.onmouseover = function () {clearinterval (MyMar)} demo.onmouseout = function () {MyMar = SetInterval ( Marquee, Speed)} </script> </div> </div>

CS Background Code:

private void Bindpics (int comid)
  {
    list<model.pic> Pic = DAO. Picdao.getpics (comid);
    StringBuilder sb = new StringBuilder ();
    if (pic = NULL | | pic. Count < 1)
    {
      imgshows.innerhtml = string. Empty;
      return;
    }
    Sb. Append ("<table width=\" 100%\ "border=\" 0\ "align=\" Center\ "cellpadding=\" 0\ "cellspacing=\" 10px\ "><tr> ");
    for (int i = 0; I < pic. Count; i++)
    {
      Model.pic p = pic[i];
      Sb. Append ("<td width=\" 200\ "><a href=\" "+ p.href +" \ "></a></td>");
    }
    Sb. Append ("</tr></table>");
    Demo1. InnerHtml = sb. ToString ();
  }

Database tables:

Use [Enterprise]
go
/****** object: Table [dbo].[ Pics]  Script Date: 03/17/2011 19:26:27 ******/
SET ansi_nulls on
go
set QUOTED_IDENTIFIER in
go
set Ansi_padding on
go
CREATE TABLE [dbo].[ Pics] (
 [Id] [int] IDENTITY (1,1) not NULL,
 [COMID] [int] NOT NULL,
 [Title] [varchar] (COLLATE) 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 = out) on [PRIMARY]
On [PRIMARY] go
SET ansi_padding off

Entity classes:

public class Pic
  {public
    int Id {set; get;}
    public int Comid {set; get;}
    Public Model.companymodel Companymodel {set; get;}
    public string Title {set;
    public string SRC {set;
    public string Href {set; get;}
  }

Above this JavaScript to achieve a simple example of the effect of a happy lantern is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.