DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
<iframe width="560" height="315" src="http://www.youtube.com/embed/GsP6h_nIhtc" frameborder="0" allowfullscreen></iframe>
You can embed this video on your blog or web page by copying the video embed code above and pasting it into the source code of your page. Adjust the width and height to specify the size you would like it to display.
Thumb Lights Out For Earth Day CSS Javascript Tutorial Dark Page Switch
Embed Source - http://www.youtube.com/watch?v=GsP6h_nIhtc
Publish Date - Jun 22, 2012     Author - Adam Khoury
Lights Out For Earth Day CSS Javascript Tutorial Dark Page Switch
Learn to create a lights out for earth day script that uses light switch graphics and contrasting style sheets to allow the user to enter dark energy saving or dark theatre mode. You can choose to use dark overlays that disable all page content, or you can use this approach which darkens the page exactly the way you want and all page elements remain fully active.
Lesson Code
<!DOCTYPE html>
<html>
<head>
<link id="pagestyle" rel="stylesheet" type="text/css" href="default.css">
<style type="text/css">
img#lightSwitch {
background:url(images/light_switch_down.jpg) no-repeat;
cursor:pointer;
}
</style>
<script type="text/javascript">
var mode = "default";
function swapStyleSheet(){
var pagestyle = document.getElementById('pagestyle');
var lightSwitch = document.getElementById('lightSwitch');
if(mode == "default"){
pagestyle.setAttribute('href', 'dark.css');
   lightSwitch.src = "images/light_switch_down.jpg";
   lightSwitch.title = "Turn the lights back on";
mode = "dark";
} else {
pagestyle.setAttribute('href', 'default.css');
   lightSwitch.src = "images/light_switch_up.jpg";
   lightSwitch.title = "Turn the lights off";
mode = "default";
}
}
</script>
</head>
<body>
<h1>CSS Javascript Lights Out Example</h1>
<img id="lightSwitch" onmousedown="swapStyleSheet()" src="images/light_switch_up.jpg" width="19" height="46" alt="switch" title="Turn the lights off"> <h3 style="display:inline;">Pink Floyd - Shine On You Crazy Diamond</h3>
<div id="special">
  <iframe width="560" height="315" src="http://www.youtube.com/embed/BLKiMbC6s2k?autoplay=1" frameborder="0" allowfullscreen></iframe>
</div>
<h2>My web page has a lot off stuff on it</h2>
</body>
</html>

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5