<html>
<head>
<style type="text/css">
.button-up {
position: absolute;
clip: rect(215px 49px 270px 0);
}
.button-down {
position: absolute;
clip: rect(0 49px 50px 0);
}
</style>
</head>
<body>
<div id="content">
<span id="upButton" style="position:absolute;top:-215;left:200;width:50px;height:50px;">
<img src="UpAndDownButtons.jpg" class="button-up" onclick="pressButton('upButton', 'downButton')"/>
</span>
<span id="downButton" style="position:absolute;top:2;left:200;width:50px;height:50px;">
<img src="UpAndDownButtons.jpg" class="button-down" onclick="pressButton('downButton', 'upButton')"/>
</span>
</div>
<script type="text/javascript">
function pressButton(fromButton, toButton) {
var from = document.getElementById(fromButton);
from.style.display = "none";
var to = document.getElementById(toButton);
to.style.display = "block";
}
function initPage() {
var up = document.getElementById("upButton");
up.style.display = "block";
var down = document.getElementById("downButton");
down.style.display = "none";
}
initPage();
</script>
</body>
</html>Wednesday, November 23, 2011
Javascript - One Image, Two Buttons
Downloading one image instead of several is one way to optimize web performance. This code shows how to use different portions of the image at various points in the page.
Past Blogs (Oldest to Newest)
- MySQL Quickstart
- Simple JUnit Example
- ANT's JavaDoc Task
- HSQLDB Console
- Elements of OO
- Variations on AS400 JDBC
- FTP Script
- Log4J Logs in DB/2
- Rhino Scripting in Java
- CSV Bulk Import
- JMock
- Internet Alphabet Soup
- Green Screen HTML Style
- Another Example - Yourself
- Groovy Script for AS400 Data
- Coad Interview of Jefferies
- More Scripting With Rhino
- Scripting With Objects
- Old School OO
- AS400 SYSPROCS
- Big Picture and Broken Windows
- Unheard Of! SQL on the AS400
- Behavioral Differences Between HashMap and TreeMap
- Sixty Second Rails
- Plum Pudding Model
- Impacting the Business
- CheatSheets
- Domain Modeling with Color?
- Maven Lifecycle and Examples
- Tomcat Basics
- Fitnesse How-To
- Ant's JAR Task
- Learning Tests for Java Dates
- Quickstart MySQL App With Maven
- Closures in Groovy
- Cohesion and Coupling
- Java Generics
- Groovy Script for Lucene
- Solient Green (and Architecture) is People
- Feeling Guilty?
- Subversion and Cruise Control
- Debugging RPG Called From JDBC
- The Value of Methodology
- Wicket in Action Quickstart
- Liquibase
- Inappropriate Infrastructure
- Idiomatic Ruby
- JRuby and Jetty