473,396 Members | 1,847 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,396 software developers and data experts.

Why will this Function work in I.E. but not in Firefox?

Dru
Am I missing something simple? I can't figure this one out...

<script language="JavaScript" type="text/javascript">
function showDesc(desc)
{
showDescription.innerText = desc;
}
</script>

<img src="images/products/item1.gif)#" width="75" height="75"
border="0" onMouseOver="showDesc('prodName');"
onMouseOut="showDesc('Mouse over image for product name')">

thnx in advance..
Jul 23 '05 #1
9 1498
Dru wrote on 04 apr 2004 in comp.lang.javascript:
Am I missing something simple? I can't figure this one out...

<script language="JavaScript" type="text/javascript">
function showDesc(desc)
{
showDescription.innerText = desc;
}
</script>

<img src="images/products/item1.gif)#" width="75" height="75"
border="0" onMouseOver="showDesc('prodName');"
onMouseOut="showDesc('Mouse over image for product name')">


Is showDescription a global variable pointing to a html container?

Only under IE, I suppose.

If it is an ID, first make a variable:

var showDescription = getElementById("showDescription")

[knowing nothing about "Firefox", btw]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
Dru <Do*********@comcast.net> writes:
Am I missing something simple? I can't figure this one out...
You are missing two simple things (and the standard completely).
<script language="JavaScript" type="text/javascript">
(The language attribute is not needed, but is not incorrect in
HTML 4 Transitional).
function showDesc(desc)
{
showDescription.innerText = desc;


You are using a (probably global) variable called "showDescription".
If you haven't declared it, it won't be there in FireFox (or many
other browsers). I guess you want it to refer to an element with
the name or id "showDescription". IE creates variables referring
to named elements, but it's not part of any standard, and many
other browsers don't. It's a FAQ entry:
<URL:http://jibbering.com/faq/#FAQ4_41>

You also use the property "innerText", which is a proprietary IE
feature. It won't work in most other browsers, including FireFox.

You can either use the more widely implemented, but just as
proprietary, innerHTML property, or you can use W3C DOM methods.
<URL:http://jibbering.com/faq/#FAQ4_15>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #3
On 04 Apr 2004 16:33:00 GMT, Evertjan. <ex**************@interxnl.net>
wrote:

[snip]
If it is an ID, first make a variable:

var showDescription = getElementById("showDescription")


You forgot to qualify the method with "document.". The call will error
without it.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
Dru
yeah i neglected to say i had a <div align="center"
id="showDescription"></div>

I'll try the innerHTML and see how that works out

On Sun, 04 Apr 2004 18:59:49 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
Dru <Do*********@comcast.net> writes:
Am I missing something simple? I can't figure this one out...


You are missing two simple things (and the standard completely).
<script language="JavaScript" type="text/javascript">


(The language attribute is not needed, but is not incorrect in
HTML 4 Transitional).
function showDesc(desc)
{
showDescription.innerText = desc;


You are using a (probably global) variable called "showDescription".
If you haven't declared it, it won't be there in FireFox (or many
other browsers). I guess you want it to refer to an element with
the name or id "showDescription". IE creates variables referring
to named elements, but it's not part of any standard, and many
other browsers don't. It's a FAQ entry:
<URL:http://jibbering.com/faq/#FAQ4_41>

You also use the property "innerText", which is a proprietary IE
feature. It won't work in most other browsers, including FireFox.

You can either use the more widely implemented, but just as
proprietary, innerHTML property, or you can use W3C DOM methods.
<URL:http://jibbering.com/faq/#FAQ4_15>

/L


Jul 23 '05 #5
Michael Winter wrote on 04 apr 2004 in comp.lang.javascript:
var showDescription = getElementById("showDescription")


You forgot to qualify the method with "document.". The call will error
without it.


Right.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #6
Dru

this is inside a .js file so the <script language="javascript"> isn't
needed.

there is a div called showDescription that I left out of my first post
... changing the innerText to innerHTML doesn't seem to help Firefox.
I'm just going to have to read up on the FAQs and probable a good JS
book.

On Sun, 04 Apr 2004 18:59:49 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
Dru <Do*********@comcast.net> writes:
Am I missing something simple? I can't figure this one out...


You are missing two simple things (and the standard completely).
<script language="JavaScript" type="text/javascript">


(The language attribute is not needed, but is not incorrect in
HTML 4 Transitional).
function showDesc(desc)
{
showDescription.innerText = desc;


You are using a (probably global) variable called "showDescription".
If you haven't declared it, it won't be there in FireFox (or many
other browsers). I guess you want it to refer to an element with
the name or id "showDescription". IE creates variables referring
to named elements, but it's not part of any standard, and many
other browsers don't. It's a FAQ entry:
<URL:http://jibbering.com/faq/#FAQ4_41>

You also use the property "innerText", which is a proprietary IE
feature. It won't work in most other browsers, including FireFox.

You can either use the more widely implemented, but just as
proprietary, innerHTML property, or you can use W3C DOM methods.
<URL:http://jibbering.com/faq/#FAQ4_15>

/L


Jul 23 '05 #7
DU
Lasse Reichstein Nielsen wrote:
Dru <Do*********@comcast.net> writes:

Am I missing something simple? I can't figure this one out...

You are missing two simple things (and the standard completely).

<script language="JavaScript" type="text/javascript">

(The language attribute is not needed, but is not incorrect in
HTML 4 Transitional).

function showDesc(desc)
{
showDescription.innerText = desc;

You are using a (probably global) variable called "showDescription".
If you haven't declared it, it won't be there in FireFox (or many
other browsers). I guess you want it to refer to an element with
the name or id "showDescription". IE creates variables referring
to named elements, but it's not part of any standard, and many
other browsers don't. It's a FAQ entry:
<URL:http://jibbering.com/faq/#FAQ4_41>

You also use the property "innerText", which is a proprietary IE
feature. It won't work in most other browsers, including FireFox.

You can either use the more widely implemented, but just as
proprietary, innerHTML property, or you can use W3C DOM methods.
<URL:http://jibbering.com/faq/#FAQ4_15>

/L


That FAQ item does not cover the W3C DOM method. When the node to
change, to update, to modify, etc.. is a text node, there is no W3C DOM
methods explained in the FAQ. Here, knowing more about the OP's page and
specifics, it would have been possible to suggest an entirely W3C
compliant code and cross-browser code like possibly:

<script type="text/javascript">
function showDesc(newDescriptiveText)
{
document.getElementById("showDescription").childNo des[0].nodeValue
= newDescriptiveText ;
}
</script>

<img src="images/products/item1.gif" width="75" height="75"
onmouseover="showDesc('prodName');" onmouseout="showDesc('Mouse over
image for product name');" alt="Descriptive alternate text">

and who knows,

<img src="images/products/item1.gif)#" width="75" height="75"
title="Mouse over image for product name" alt="Descriptive alternate
text">

could have been more than sufficient ... if we only had known what was
the webpage context.

DU
Jul 23 '05 #8
On Sun, 04 Apr 2004 17:26:52 GMT, Dru <Do*********@comcast.net> wrote:

[snip]
there is a div called showDescription that I left out of my first post
.. changing the innerText to innerHTML doesn't seem to help Firefox.
Because that wasn't the only issue addressed in Lasse's post. The problem
of using an element's id attribute value as a global variable is also a
problem.
I'm just going to have to read up on the FAQs and probable a good JS
book.


That would be a good idea. :)

Mike

[snipped top-post quotation]

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #9
DU
Dru wrote:
this is inside a .js file so the <script language="javascript"> isn't
needed.

You still need to use the proper attribute when embedding an external
..js file:

<script type="text/javascript" href="path/filename.js"></script>
there is a div called showDescription that I left out of my first post
... changing the innerText to innerHTML doesn't seem to help Firefox.
Evertan suggested to you to use the getElementById method which is
widely supported by browsers (MSIE 5+) and is W3C compliant.
I'm just going to have to read up on the FAQs and probable a good JS
book.

2 urls I recommend to first visit (which are mentioned in the
comp.lang.javascript FAQ):

Using Web Standards in Your Web Pages
http://www.mozilla.org/docs/web-deve...upgrade_2.html

Updating DHTML Web Pages for next generation browsers
http://devedge.netscape.com/viewsour...tml-web-pages/

These 2 urls have tips and tricks and fit well your questions and
difficulties.

DU
On Sun, 04 Apr 2004 18:59:49 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:

Dru <Do*********@comcast.net> writes:

Am I missing something simple? I can't figure this one out...


You are missing two simple things (and the standard completely).

<script language="JavaScript" type="text/javascript">


(The language attribute is not needed, but is not incorrect in
HTML 4 Transitional).

function showDesc(desc)
{
showDescription.innerText = desc;


You are using a (probably global) variable called "showDescription".
If you haven't declared it, it won't be there in FireFox (or many
other browsers). I guess you want it to refer to an element with
the name or id "showDescription". IE creates variables referring
to named elements, but it's not part of any standard, and many
other browsers don't. It's a FAQ entry:
<URL:http://jibbering.com/faq/#FAQ4_41>

You also use the property "innerText", which is a proprietary IE
feature. It won't work in most other browsers, including FireFox.

You can either use the more widely implemented, but just as
proprietary, innerHTML property, or you can use W3C DOM methods.
<URL:http://jibbering.com/faq/#FAQ4_15>

/L


Jul 23 '05 #10

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

Similar topics

4
by: nec | last post by:
Hi, I'm having trouble calling a function thats located in a iFrame from the parent. Shortly, i can't figure out the location in DOM. In IE it works fine with a simple line of...
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
7
by: Amir | last post by:
I have a common Jscript function in my "common.js" file It is: function submitForm(frm,action){ frm.action=action; frm.submit(); return(false) }
1
by: acl123 | last post by:
Hi, I am trying to work out how to access the event object in firefox under two conditions - 1) Attaching event handlers in javascript, not html. 2) The event handler requires parameters in...
6
by: yawnmoth | last post by:
I'm trying to write a so-called bookmarklet for a specific web app and am having some difficulty. One of the names of a specific forms inputs is submit. As such, doing...
2
by: JDeats | last post by:
>From my development envrionment (i.e. a single WinXP notebook PC) I have a basic AJAX application that is making the call to a Windows Form page that just returns the request back to the AJAX...
1
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function...
1
by: marss | last post by:
On Apr 30, 3:42 pm, "Beauregard T. Shagnasty" <a.nony.m...@example.invalidwrote: For exUSSR Opera share is a little more. I do not worry about Opera prospect, I worry about the task I 've got...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.