JavaScript
  Home arrow JavaScript arrow Page 3 - Special Effects with DHTML Rollovers
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Special Effects with DHTML Rollovers
By: Ian Felton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 16
    2004-09-28

    Table of Contents:
  • Special Effects with DHTML Rollovers
  • Enter the JavaScript
  • The Main Effect and Implementation
  • Putting it all Together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Special Effects with DHTML Rollovers - The Main Effect and Implementation


    (Page 3 of 4 )

    Now it’s time for the main effect function. Are you shuddering? If not, hopefully soon you will be. The Shudder function is actually very simple. It consists two variables, x and y which are random numbers. The final two lines move the shuddering image. The top and left position of the background image are erratically shifted within a set of bounds created with the random numbers and some logarithmic functions. The equation’s purpose is to shudder the image, but not too much.

    function Shudder() {
    var x = Math.random();
    var y = Math.random();
    Behindobj.top = (available_height / 2) - (145 * y) - (Math.cos(x *10) + (x * y));
    Behindobj.left = (available_width / 2) - (100 * x) - (Math.sin(y *10) + (2 * y * ));
    }

    That is the bulk of the code explained in detail. All that is left is to assign the images to DIV tags within the body of the HTML page and initialize the functions in the proper order. Using the onLoad function within the BODY tag, the size of the screen is determined, the style sheet syntax is standardized and the style sheet variable names are instantiated. The two DIV tags associate the images with the style sheet variable that were defined in the very beginning. An onMouseMove command is placed within the top image so that the Shudder effect is called when appropriate.

    <BODY BGCOLOR="BLACK" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLL="NO" onLoad="
    if(is.ns4) {
         available_width=innerWidth;
         available_height=innerHeight;
       }
               else if(is.ie4) {
         available_width=document.body.clientWidth;
         available_height=document.body.clientHeight;
      };
    standardize(); Load_Name(); setTimeout('Position()',.01);">
    <DIV ID="Central"><IMG SRC="graphics/sundunes.jpg" width="422" height="286" onmousemove="Shudder()"></DIV>
    <DIV ID="Behind"><IMG SRC="graphics/sundunes_b.jpg"></DIV>

    </BODY>

    More JavaScript Articles
    More By Ian Felton


       · Eh, why on earth would you use js for this when you have the :hover css-property? It...
       · Thanks for the post.Hover is useful, but the article was demonstrating how to...
       · Check out the cited example site (http://unitedbands.com/devArticles/shudder.html)...
       · .... doesn't work in Mozilla.
       · The shudder effect was tested on IE 6 and Opera 6.5 where it works fine. I'm sure...
       · Are not really helpful in a web environment that strives for standard compliance and...
       · If I hear one more silly rant about compatibility (which really means homogenizing...
       · Sure it's a neat effect but no rubbish about web standards being a homogenisation...
     

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT