473,241 Members | 1,488 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,241 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 3530
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. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

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.