• JavaScript实现漫天飞花及文字滚动特效的代码


    代码简介:

    漫天飞花及文字滚动特效,不知道该怎么形容这种效果,它是图片和文字相结合的一种特效,就叫做漫天飞花吧,另外它还可以控制一组文字上下滚动,也就走马灯,个性十足。

    代码内容:

    View Code
    <title>JavaScript实现漫天飞花及文字滚动特效的代码 - www.webdm.cn</title>
    <SCRIPT language=JavaScript>
    //设置marquee的宽度(in pixels)
    var marqueewidth=190
    //设置marquee的高度
    var marqueeheight=200
    //设置marquee的速度
    var speed=1
    //设置marquee的显示内容
    var marqueecontents=

    ef
    ="<center><p>网页代码站(Webdm.cn)</center>"

    if (document.all)
    document.write(
    '<marquee direction="up" scrollAmount='+speed+' style="'+marqueewidth+';height:'+marqueeheight

    +'">'+marqueecontents+'</marquee>')

    function regenerate(){
    window.location.reload()
    }
    function regenerate2(){
    if (document.layers){
    setTimeout(
    "window.onresize=regenerate",450)
    intializemarquee()
    }
    }

    function intializemarquee(){
    document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
    document.cmarquee01.document.cmarquee02.document.close()
    thelength
    =document.cmarquee01.document.cmarquee02.document.height
    scrollit()
    }

    function scrollit(){
    if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
    document.cmarquee01.document.cmarquee02.top
    -=speed
    setTimeout(
    "scrollit()",100)
    }
    else{
    document.cmarquee01.document.cmarquee02.top
    =marqueeheight
    scrollit()
    }
    }

    window.onload
    =regenerate2
    </SCRIPT>

    <script language="JavaScript1.2"><!-- Begin
    var no = 20;
    var speed = 10;
    var snowflake = "http://www.webdm.cn/themes/pic/webdm_logo.gif";

    var ns4up = (document.layers) ? 1 : 0;
    var ie4up = (document.all) ? 1 : 0;
    var dx, xp, yp;
    var am, stx, sty;
    var i, doc_width = 800, doc_height = 600;
    if (ns4up) {
    doc_width
    = self.innerWidth;
    doc_height
    = self.innerHeight;
    }
    else if (ie4up) {
    doc_width
    = document.body.clientWidth;
    doc_height
    = document.body.clientHeight;
    }
    dx
    = new Array();
    xp
    = new Array();
    yp
    = new Array();
    am
    = new Array();
    stx
    = new Array();
    sty
    = new Array();
    for (i = 0; i < no; ++ i) {
    dx[i]
    = 0;
    xp[i]
    = Math.random()*(doc_width-50);
    yp[i]
    = Math.random()*doc_height;
    am[i]
    = Math.random()*20;
    stx[i]
    = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    if (ns4up) {
    if (i == 0) {
    document.write(
    "<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snowflake + "\"

    border=\"0\"></layer>
    ");
    }
    else {
    document.write(
    "<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\"" + snowflake + "\"

    border=\"0\"></layer>
    ");
    }
    }
    else if (ie4up) {
    if (i == 0) {
    document.write(
    "<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px;

    LEFT: 15px;\"><img src=\"
    " + snowflake + "\" border=\"0\"></div>");
    }
    else {
    document.write(
    "<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px;

    LEFT: 15px;\"><img src=\"
    " + snowflake + "\" border=\"0\"></div>");
    }
    }
    }
    function snowNS() {
    for (i = 0; i < no; ++ i) {
    yp[i]
    += sty[i];
    if (yp[i] > doc_height-50) {
    xp[i]
    = Math.random()*(doc_width-am[i]-30);
    yp[i]
    = 0;
    stx[i]
    = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width
    = self.innerWidth;
    doc_height
    = self.innerHeight;
    }
    dx[i]
    += stx[i];
    document.layers[
    "dot"+i].top = yp[i];
    document.layers[
    "dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout(
    "snowNS()", speed);
    }

    function snowIE() {
    for (i = 0; i < no; ++ i) {
    yp[i]
    += sty[i];
    if (yp[i] > doc_height-50) {
    xp[i]
    = Math.random()*(doc_width-am[i]-30);
    yp[i]
    = 0;
    stx[i]
    = 0.02 + Math.random()/10;
    sty[i] = 0.7 + Math.random();
    doc_width
    = document.body.clientWidth;
    doc_height
    = document.body.clientHeight;
    }
    dx[i]
    += stx[i];
    document.all[
    "dot"+i].style.pixelTop = yp[i];
    document.all[
    "dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
    }
    setTimeout(
    "snowIE()", speed);
    }
    if (ns4up) {
    snowNS();
    }
    else if (ie4up) {
    snowIE();
    }
    // End -->
    </script>
    <br />
    <p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的网页代码下载网站 - 致力为中国站长提供有质量的网页代码!

    </p>

    代码来自:http://www.webdm.cn/webcode/3580774a-078a-470e-8fbd-a25aaec5e24f.html

  • 相关阅读:
    linux进程和调度
    linux驱动设备树
    linux驱动开发3
    字符设备驱动开发
    驱动内存分配api说明(转转)
    linux驱动里面双向链表
    好用的开源代码(库,操作系统,gui)等等
    linux驱动并发逻辑
    字符驱动开发2
    android view可见性判断(判断是否在屏幕中显示)
  • 原文地址:https://www.cnblogs.com/webdm/p/2305767.html
Copyright © 2020-2023  润新知