Page 3 of 3 FirstFirst 123
Results 21 to 21 of 21

Thread: [DHTML] Floaty UFO

  1. #21
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    HTML Code:
    <script type="text/javascript">
    
    var xobjectsize = 144
    var yobjectsize = 52
    var xstep = (Math.round(Math.random(new Date().getMilliseconds()))*600)-300
    var ystep = 600
    var degstep = 2
    var xstepsize = "big"
    var ystepsize = "big"
    var circledeg = -90
    var clicked = "no"
    
    if (typeof document.body.scrollTop !== "undefined")
     {
      imagescrollpos = document.body.scrollTop-2000
      heightwindow = document.body.offsetHeight
      widthwindow = document.body.offsetWidth
     }
    if (typeof window.pageYOffset !== "undefined")
     {
      imagescrollpos = window.pageYOffset-2000
      heightwindow = innerHeight
      widthwindow = innerWidth
     }
    
    function circledraw()
    {
    var circlerad = (circledeg*(2*Math.PI/360))*degstep
    var sindraw=Math.round(Math.sin(circlerad)*ystep)+(heightwindow/2)-(xobjectsize/2)
    var cosdraw=Math.round(Math.cos(circlerad)*xstep)+(widthwindow/2)-(xobjectsize/2)
    if (typeof document.body.scrollTop !== "undefined")
     {
      scrolloffset = document.body.scrollTop
      heightwindow = document.body.offsetHeight
      widthwindow = document.body.offsetWidth
     }
    if (typeof window.pageYOffset !== "undefined")
     {
      scrolloffset = window.pageYOffset
      heightwindow = innerHeight
      widthwindow = innerWidth
     }
    if (imagescrollpos<scrolloffset)
     {
      imagescrollpos += (Math.ceil((scrolloffset-imagescrollpos)/50))
     }
    if (imagescrollpos>scrolloffset)
     {
      imagescrollpos -= (Math.ceil((imagescrollpos-scrolloffset)/50))
     }
    var es = document.getElementById("spaceship")
    es.style.visibility = "visible"
    es.style.left=cosdraw
    es.style.top=sindraw + imagescrollpos
    liftoff = sindraw + imagescrollpos
    wobble = cosdraw
    circledeg++
    if (xstep>=widthwindow/2)
     {
      xstepsize = "small"
     }
    if (ystep>=heightwindow/2)
     {
      ystepsize = "small"
     }
    if (xstep<=-widthwindow/2)
     {
      xstepsize = "big"
     }
    if (ystep<=-heightwindow/2)
     {
      ystepsize = "big"
     }
    
    if (xstepsize=="big")
     {
      xstep++
     }
    else
     {
      xstep--
     }
    if (ystepsize=="big")
     {
      ystep++
     }
    else
     {
      ystep--
     }
    if (clicked=="no")
     {
      setTimeout(circledraw, 50)
     }
    }
    setTimeout(circledraw, 1000)
    
    function goaway()
    {
    clicked = "yes"
    var es = document.getElementById("spaceship")
    es.style.top = liftoff
    es.style.left = wobble + Math.round(Math.random(new Date().getMilliseconds())*20)-10
    liftoff-=5
    if (liftoff>=-100)
     {
      setTimeout(goaway, 50)
     }
    else
     {
      es.style.visibility = "hidden"
     }
    }
    
    
    
    
    </script>
    
    <script type="text/javascript">
    document.write('<div id="body">');
    for (ytesttext=1 ; ytesttext <=2000 ; ytesttext++)
     {
      document.write("Test text " + ytesttext + " the webpage goes here, the webpage goes here, the webpage goes here, the webpage goes here, the webpage goes here, the webpage goes here.  <br>")
     }
    document.write('</div>');
    </script></body></html>
    Sorry about the cutoff, I had to shorten it to 10,000 chars. (Why do they have that requirement?)
    I haven't tried it yet and it disables the horizontal scrollbar.
    The second code comes after the first.
    Last edited by techno_race; 04-12-2007 at 02:58 AM. Reason: had a copy of a div; was missing one
    ....(o_ Penguins
    .---/(o_- techno_racing
    +(---//\-' in
    .+(_)--(_)' The McMurdo 500

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
  •