Results 1 to 3 of 3

Thread: cursor

  1. #1
    Join Date
    May 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default cursor

    is there any way to modify the code on this page so that it is blinking different colors. thanks

    http://www.dynamicdrive.com/dynamici...railortext.htm

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Try this out, it seems to work pretty well in IE6, OP8 and FF:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>Cursor Trailer Blinking Color - Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    .spanstyle {
        position:absolute;
        visibility:visible;
        top:-50px;
        font-size:10pt;
        font-family:Verdana;
    font-weight:bold;
    }
    
    </style>
    
    
    <script type="text/javascript">
    
    /*
    Cursor Trailer Text- By Peter Gehrig (http://www.24fun.ch/)
    Permission given to Dynamicdrive.com to feature script in it's archive.
    For full source code, installation instructions, and 1000's more DHTML scripts,
    visit http://dynamicdrive.com & http://dynamicdrive.com/forums
    Modified in Dynamic Drive Help Forums by jscheuer1
    */
    
    //Set below for optimal contrast ('0' if your page's background is light,
    //'f' for a page with a dark background
    var bk='0'
    
    // Your snappy message. Important: the space at the end of the sentence!!!
    var message="DYNAMIC DRIVE! "
    
    /////////////// Stop Editing ///////////
    
    function iecompattest(){
    return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
    }
    
    message=message.split("")
    var x,y
    var step=20
    var flag=0
    var fac=document.all? 10 : 0
    
    var xpos=new Array()
    for (i=0;i<=message.length-1;i++) {
        xpos[i]=-50
    }
    
    var ypos=new Array()
    for (i=0;i<=message.length-1;i++) {
        ypos[i]=-50
    }
    
    function handlerMM(e){
    if ((document.getElementById)&&(!document.all)){
    x =  e.pageX
    y =  e.pageY
        flag=1
    }
    else{
        x = (document.layers) ? e.pageX : iecompattest().scrollLeft+event.clientX
        y = (document.layers) ? e.pageY : iecompattest().scrollTop+event.clientY
        flag=1
    }
    }
    
    function makesnake() {
        if (flag&&(document.all||document.getElementById)) {
        for (i=message.length-1; i>=1; i--) {
                xpos[i]=xpos[i-1]+step
                ypos[i]=ypos[i-1]
        }
            xpos[0]=x+step
            ypos[0]=y
       
            for (i=0; i<message.length-1; i++) {
            var thisspan = document.all? document.all['span'+i].style : document.getElementById('span'+i).style
    if (iecompattest().offsetWidth){
    var docFac=document.all? window.opera? 16 : 32 : 23
    if (xpos[i]>iecompattest().offsetWidth-docFac)
    thisspan.display='none'
    else
    thisspan.display='block'
    }
    if (document.getElementById&&!document.all){
            thisspan.left=xpos[i]+'px'
                thisspan.top=ypos[i]+'px'  
    }
    else{
            thisspan.posLeft=xpos[i]
                thisspan.posTop=ypos[i]
    }
        }
        }
       
        else if (flag&&document.layers) {
        for (i=message.length-1; i>=1; i--) {
                xpos[i]=xpos[i-1]+step
                ypos[i]=ypos[i-1]
        }
            xpos[0]=x+step
            ypos[0]=y
       
            for (i=0; i<message.length-1; i++) {
            var thisspan = eval("document.span"+i)
            thisspan.left=xpos[i]+'px'
                thisspan.top=ypos[i]+'px'
        }
        }
            var timer=setTimeout("makesnake()",fac*3)
    }
    
    </script>
    
    </head>
    <body onLoad="makesnake()" >
    <script type="text/javascript">
    
    function random(n) {
      return Math.floor((Math.random() % 1) * n);
    }
    
    function blinkColor(num){
    var a=random(16).toString(16)
    var b=random(16).toString(16)
    var c=random(16).toString(16)
    var el='span'+num
    el=document.getElementById(el)
    el.style.color='#'+a+bk+b+bk+c+bk
    }
    
    
    for (i=0;i<=message.length-1;i++) {
    var a=random(16).toString(16)
    var b=random(16).toString(16)
    var c=random(16).toString(16)
    document.write("<span id='span"+i+"' style='color:#"+a+bk+b+bk+c+bk+"' class='spanstyle'>")
        document.write(message[i])
    document.write("</span>")
    setInterval("blinkColor("+i+")",(random(16)+1)*fac)
    }
    
    if (document.layers){
        document.captureEvents(Event.MOUSEMOVE);
    }
    document.onmousemove = handlerMM;
    
    </script>
    
    </body>
    </html>
    
    Copyright  1998-2005 Dynamic Drive. Please read Terms Of Use here before using any of the scripts.
    Last edited by jscheuer1; 10-10-2005 at 08:10 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •