I'm trying to figure out why this script will work in IE 6 but not
Firefox, and so I need someone here with a far better grasp on
javascript to explain this. Basically, I have a page with several
thumbnails. Above these thumbnails I placed a large picture with text
next to it to describe what the picture is about. So, when you click a
thumb, the large pic AND text change dynamically to reflect the
thumbnail -- see http://www.chadsmoore.com/pjstarhomeless -- for a
live example.
The scripts on my web page are located in the head section. I have
provided the script below . The "while" condition is used to prevent
the text from appending to each other after each click.
This script works perfectly in IE 6, but won't work in Firefox.
Any suggestions to making this work in Firefox would be greatly
appreciated.
Thanks in advance!
// script to change text -- thumbnail 1
function homelessbwWoman(){
while (content.hasChildNodes()) {
content.removeChild(content.lastChild);
}
var txt = 'Tamara Maslanka takes a telephone call for a client at the
Illinois Valley Public Action to Deliver Shelter location in Ottawa.
Maslanka now directs operations at the shelter where she and her family
once lived.';
var txtn= document.createTextNode(txt);
document.getElementById("content").appendChild(txt n);
}
// script to change text -- thumbnail 2
function homelessbwFlorist(){
while (content.hasChildNodes()) {
content.removeChild(content.lastChild);
}
var txt = 'Robert Maslanka puts together a floral arrangement at TPM
Stems in Ottawa. The upscale floral and interior landscape design shop
hired Maslanka while he and his wife resided at the IVPADS shelter. The
job, with hours donated by other employees, helped the Maslankas get on
their feet and out of a homeless situation.';
var txtn= document.createTextNode(txt);
document.getElementById("content").appendChild(txt n);
}
// Change Image Script
function canManipulateImages() {
if (document.images)
return true;
else
return false;
}
function loadHomelesslg(imageURL) {
if (gImageCapableBrowser) {
document.homelessLG.src = imageURL;
return false;
}
else {
return true;
}
}
gImageCapableBrowser = canManipulateImages();
// relevant body code
<tr>
<td width="240">
<!-- Large Image -->
<img src="thumbnails/bwWoman_lg.jpg" height="174" width="240"
id="homelessLG" name="homelessLG" alt="" />
</td>
<td>
<!-- Div element named "content" containing dynamic text -->
<div id="content" class="picContent">
Tamara Maslanka takes a telephone call for a client
at the Illinois Valley Public Action to Deliver Shelter location in
Ottawa. Maslanka now directs operations at the shelter where she and
her family once lived.
</div>
</td>
</tr>
// Two cells each containing clickable thumbnails
<table>
<tr>
<td>
<a href="#" onclick="homelessbwWoman();
return(loadHomelesslg('thumbnails/bwWoman_lg.jpg'));"><IMG
alt=DAILY_PICS-MASLANKA1_BW
src="thumbnails/bwWoman_th.jpg"
width="75" height="56"></a>
</td>
<td>
<a
href="#" onClick="homelessbwFlorist();
return(loadHomelesslg('thumbnails/bwManFloral_lg.jpg'));" ><IMG
alt=DAILY_PICS-MASLANKA3_BW
src="thumbnails/bwManFloral_th.jpg" width="75"
height="56"></a>
</td>
</tr>
</table>