Spot light : Animation « GUI Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Form Control
10. GUI Components
11. HTML
12. Javascript Collections
13. Javascript Objects
14. jQuery
15. Language Basics
16. Node Operation
17. Object Oriented
18. Page Components
19. Security
20. Style Layout
21. Table
22. Utilities
23. Window Browser
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorial
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » GUI Components » Animation 
Spot light

/*
DO NOT USE A TILED BACKGROUND IMAGE ON THE PAGE USING THIS SCRIPT. 
It causes a lagging effect even on a modern computer.

Paste this style sheet to the head of your page or add 
its contents to an existing one.

EXCEPT for background-color in #content, 
do not alter or add to #content or #light! 

<style type="text/css">
<!--
body{
background-image : none ! important;
}

#content{
background-color : #ffffff;
position : absolute;
top : 0px;
left : 0px;
padding : 10px;
visibility : hidden;
}

#light{
position : absolute;
top : 0px;
left : 0px;
overflow : hidden;
z-index : 500;
}
//-->
</style>




Paste this js link IMMEDIATELY after the opening <body> tag.

<script type="text/javascript" src="spotlight_part_1.js"></script>



Paste this js link as the very last thing just before the </body></html> tags.

<script type="text/javascript" src="spotlight_part_2.js"></script>





Example:

<body>
<script type="text/javascript" src="spotlight_part_1.js"></script>


Your content here.........


<script type="text/javascript" src="spotlight_part_2.js"></script>
</body>
</html>
*/


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Spotlight</title>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">


<style type="text/css">
<!--
body{
background-image : none ! important;
}

#content{
background-color : #ffffff;
position : absolute;
top : 0px;
left : 0px;
padding : 10px;
visibility : hidden;
}

#light{
position : absolute;
top : 0px;
left : 0px;
overflow : hidden;
z-index : 500;
}
//-->
</style>


</head>
<body>
<script type="text/javascript">
var noOpe = window.toString();
if  (noOpe != "[object Object]"){  
 if  ((document.getElementById&& window.addEventListener || window.attachEvent){
  document.body.style.backgroundColor = "#000000";
  document.write('<div id="content"><div id="light"><img src="spotlight.gif" alt="" onclick="reveal()"/><\/div>');
 }
}
</script>




<script type="text/javascript">
//Spot Light http://www.btinternet.com/~kurt.grigg/javascript


var noOpe = window.toString();
if  (noOpe != "[object Object]"){ 

if  ((document.getElementById&& 
window.addEventListener || window.attachEvent){


document.write('<\/div>');


var spotLightImage = new Image(124,124);
spotLightImage.src = "spotlight.gif";

var r,h,w,y,x,spotLightDiv,yourContentDiv;
var d = document;




var domWw = (typeof window.innerWidth == "number");
var domSy = (typeof window.pageYOffset == "number");

if (domWwr = window;
else
  if (d.documentElement && 
  typeof d.documentElement.clientWidth == "number" && 
  d.documentElement.clientWidth != 0)
  r = d.documentElement;
 else
  if (d.body && 
  typeof d.body.clientWidth == "number")
  r = d.body;
 }
}



function winsize(){
var oh,sy,ow,sx,rh,rw;
var scy = (domSy)?r.pageYOffset:r.scrollTop;
var scx = (domSy)?r.pageXOffset:r.scrollLeft;

if (domWw){
   if (d.documentElement && d.defaultView && 
   typeof d.defaultView.scrollMaxY == "number"){
    oh = d.documentElement.offsetHeight;
    sy = d.defaultView.scrollMaxY;
    ow = d.documentElement.offsetWidth;
    sx = d.defaultView.scrollMaxX;
    rh = oh-sy;
    rw = ow-sx;
   }
   else{
    rh = r.innerHeight;
    rw = r.innerWidth;
   }
  h = rh; 
  w = rw;
  }
 else{
  h = r.clientHeight; 
  w = r.clientWidth;
 }

var con_h,con_w;
if (!window.opera && d.documentElement && 
 typeof d.documentElement.scrollHeight == "number" && 
 d.documentElement.scrollHeight != 0){
  con_h = d.documentElement.scrollHeight;
  con_w = d.documentElement.scrollWidth;
 }
else
 if (d.body && 
 typeof d.body.scrollHeight == "number"){
  con_h = d.body.scrollHeight;
  con_w = d.body.scrollWidth;
 }
}
var r_h = (con_h > h)?con_h:h;
var r_w = (con_w > w)?con_w:w;

yourContentDiv.height = r_h-20 "px";
yourContentDiv.width = r_w-20 "px";
}

function mouseControl(needed){
if (window.addEventListener){
 if (needed){
  document.addEventListener("mousemove",mouse,false);
 }
 else
  document.removeEventListener("mousemove",mouse,false);
 }
}  
if (window.attachEvent){
 if (needed){
  document.attachEvent("onmousemove",mouse);
 }
 else
  document.detachEvent("onmousemove",mouse);
 }
}
}


function mouse(e){
var scy = (domSy)?r.pageYOffset:r.scrollTop;
var scx = (domSy)?r.pageXOffset:r.scrollLeft;
if (!ee = window.event;    
 
if (typeof e.pageY == "number"){
 y = e.pageY - spotLightImage.height/2;
 x = e.pageX - spotLightImage.width/2;
}
else{
 y = e.clientY - spotLightImage.height/+ scy;
 x = e.clientX - spotLightImage.width/+ scx;
}

if (y >= (h+scy)-spotLightImage.height-5){ 
 y = (h+scy)-spotLightImage.height-5;
}
if (x >= (w+scx)-spotLightImage.width){ 
 x = (w+scx)-spotLightImage.width;
}
  
yourContentDiv.clip = "rect("+y+"px "+(x+spotLightImage.width)+"px "+(y+spotLightImage.height)+"px "+x+"px)";
yourContentDiv.visibility = "visible";
spotLightDiv.top = y + "px";
spotLightDiv.left = x + "px";
}


function reveal(){
mouseControl(false);
spotLightDiv.visibility = "hidden";
yourContentDiv.clip = "rect(auto auto auto auto)";
}


function init(){
yourContentDiv = document.getElementById("content").style;
spotLightDiv = document.getElementById("light").style;
winsize();
mouseControl(true);
}


function rld(){
window.location.reload();
//Not ideal but far too much messing about other wise!
}


if (window.addEventListener){
 window.addEventListener("load",init,false);
 window.addEventListener("resize",rld,false);
}  
else if (window.attachEvent){
 window.attachEvent("onload",function(){init();});
 window.attachEvent("onresize",function(){rld();});



}//End.
}

</script>
</body>
</html>

           
       
spotlight.zip( 3 k)
Related examples in the same category
1. Attack animation
2. Circle Animation
3. Right to left animation
4. Flash animation in Javascript
5. Flash animation in JavaScript: Changing style Properties
6. Animation along Straight Line
7. Animation along a Circle
8. Dancing Text (IE)
9. Type Writer effect (IE)
10. Type Writer Effect 1.1 (IE)
11. JavaScript Ticker 1.2 (IE)
12. Animation: Lottery Number Picker and Statistics
13. Animation: wriggly
14. Animation: welcome message
15. Animation: trio
16. Auto lotto dip
17. Animation: snow
18. Animation: star
19. Animation: mouse doodle
20. Animation: fireworks
21. Animation: pretty
22. Animation: Random Movement
23. Lotto number draw
24. Following eyes
25. Animation: three eyes
26. Animation: eyes
27. Big static eyes
28. Animation based on DIV with color flash
29. Framework for creating CSS-based animations
30. Animate dynamic element h1 tag
31. Popup window animation (fly across screen)
32. Animation on several images
33. Using the onFilterChange Event Handler
34. JavaScript Animation
35. Periodically Updating the Text Displayed by an HTML Element
36. Moving an Airplane Across a Web Page
37. Link Hint Scroller 2.0 (IE)
38. Snow animation
w_w___w_.___j_a___v___a2s.__c_om | |Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.