Sunny's Technology Blog

书山有路勤为径,学海无涯苦作舟

博客园 首页 新随笔 联系 订阅 管理
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<script runat="server">
    protected 
void Page_Load(object sender, EventArgs e)
    
{
        
// 为btnTest控件添加onmouseover和onmouseout客户端行为
        this.btnTest.Attributes.Add("onmouseover""MakeRed();");
        
this.btnTest.Attributes.Add("onmouseout""RestoreColor();");


        String scriptText 
= "return confirm('要提交吗??')";
        
//添加页面提交时执行的脚本。
        ClientScript.RegisterOnSubmitStatement(typeof(string), "ConfirmSubmits", scriptText);

    }
    
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>Untitled Page</title>
    
<script type="text/javascript">
        
var previousColor;
        
// 改变前景色
        function MakeRed(){
            previousColor 
= window.event.srcElement.style.color;
            window.event.srcElement.style.color 
= "#FF0000";
        }

        
// 恢复原前景色
        function RestoreColor(){
               window.event.srcElement.style.color 
= previousColor;
        }

    
</script>
</head>
<body>
    
<form id="form1" runat="server">
        
<asp:button id="btnTest" text="btnTest" runat="server" />
        
<asp:button id="Button1" text="btnTest" runat="server" />
        
<!--
            要用两个 <div> 来实现滚动行的效果
        
-->
        
<div id="div1" style="overflow: hidden; height: 80px; margin-top: 20px; padding-bottom: 20px; width: 293px; clip: rect(auto auto auto auto); top: 0px; position: relative; left: 0px;">
        
<div id="div2" style="position: relative;">
        
<ul><li>a</li><li>b</li><li>c</li><li>d</li><li>e</li><li>f</li><li>g</li><li>gg</li></ul>
        
</div>
        
</div>
        
    
</form>
    
<script type="text/javascript">   
    
var curTop = 0;
    
var timer  = 0;
    
    setInterval('scrollUp()', 
3000);  //这里的 3000 指每隔这么长时间就执行一次滚动
    
    
//为了保持滚动的连贯视觉,
    //我们将一次滚动操作转换成很多次的小滚动来实现
    function scrollUp(){
        
if(curTop<-140)  curTop = 0;  //如果已经滚动到最低,重新设置到最顶端    
        
        curTop 
= curTop - 1;  //每次小滚动向上滚动一个像素单位
        div2.style.top = curTop;
        
        
if(timer == 19)       //因为一行有 19 像素高,所以如果已经滚动完一行高度,就重置,并停止本次滚动
        {
            timer 
= 0;
        }

        
else
        
{
            timer 
= timer + 1;
            setTimeout('scrollUp()', 
30); //我们每隔 30 毫秒进行一次滚动
        }
          
    }

    
</script>
</body>
</html>
posted on 2006-06-15 15:06  Sunny  阅读(756)  评论(0)    收藏  举报