473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Script works in IE 6, but not Firefox -- Need Help!

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>

Jul 6 '06 #1
2 3534
I think it's because your variable 'content' isn't assigned explicitly.
You need a line
like this that is executed when the document loads
<body onload="content = document.getElementById( 'content' );">
or just place it at the bottom of the page.

<script type="text/javascript">
content = document.getElementById( 'content' );
</script>
</html>

I think IE will attempt to find the element with id 'content' if you
haven't defined it as a variable.

ranger7419 wrote:
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>
Jul 6 '06 #2

bobzimuta wrote:
I think it's because your variable 'content' isn't assigned explicitly.
You need a line
like this that is executed when the document loads
<body onload="content = document.getElementById( 'content' );">
or just place it at the bottom of the page.

<script type="text/javascript">
content = document.getElementById( 'content' );
</script>
</html>

I think IE will attempt to find the element with id 'content' if you
haven't defined it as a variable.

Awesome. Problem solved. Thanks a million, bobzimuta!

Jul 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Szlazak | last post by:
Apparently there is a textarea onscroll event bubbling bug in Firefox and Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=229089 I'm trying to check for this bug with the following...
3
by: Razvan | last post by:
Hello, Can somebody recommend me a Java Script scroller that can scroll an i-frame ? I tried the Tigra scroller (www.softcomplex.com/products/tigra_scroller/) but sometimes it does not...
3
by: niconedz | last post by:
Hi The following code works fine in IE but not Firefox. It's a little script that zooms an image and resizes the window to fit. Can anybody tell me what's wrong? Thanks Nico == btw.....
7
by: Joseph Scoccimaro | last post by:
Currently I am trying to use JavaScript within greasemonkey to dynamically put a menu at the top of each page. I am running in to trouble when I try to append a node representing a script tag to...
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
6
by: goober | last post by:
Ladies & Gentlemen: I have built a form that client-side validates and posts data to a CRM beautifully in Internet Explorer (IE) 6. The problem comes in FireFox (FF) 1.5 when everything works...
4
by: aramsey | last post by:
I have a javascript program that works fine under Firefox and on IE when running XP, but is having a problem with IE running under Windows 2000 Pro. On my personal XP development machine I have...
2
by: willyWEB66 | last post by:
Hi everyone, I have this code in javascript where the XML file is loaded and displayed to an html using XSLT. It works fine in IE but not in Firefox. My problem is in the looping to the...
7
by: mike57 | last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.