topical media & game development
basic-ajax-02-Ch2-examp3.htm / htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Event Registration</title>
<script type="text/javascript">
function addHandler () {
var addH = document.getElementById('p1');
if (addH.addEventListener) {
addH.addEventListener('click', addBord, false);
}
else if (addH.attachEvent) {
addH.attachEvent('onclick', addBord);
}
}
function detHandler () {
var detH = document.getElementById('p1');
detH.style.border = '';
detH.style.backgroundColor = '#ffffff';
if (detH.removeEventListener) {
detH.removeEventListener('click', addBord, false);
}
else if (detH.detachEvent) {
detH.detachEvent('onclick', addBord);
}
}
function addBord () {
var add = document.getElementById('p1');
add.style.border = '1px dotted #ff0000';
add.style.backgroundColor = '#ffff99';
}
</script>
</head>
<body onload="addHandler()">
<p id='p1'>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed scelerisque odio non ligula. </p>
<p>Integer mollis, libero et facilisis hendrerit, tellus dui porttitor quam, vitae iaculis nisi mauris ac dui. Vivamus volutpat sollicitudin est. </p>
<form>
<input type='button' value='No border, please!' onclick='detHandler()'>
</form>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.