473,396 Members | 1,929 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.

JavaScript Error in FireFox

Cy
Hi, I have a menu that toggles correctly in IE but is failing in
FireFox V.1 and Netscape 7.1. The FireFox JavaScript Console is
returning the following error; Error: document.getElementById(showDiv)
has no properties.

Any advice would be much appreciated. Here is the snippet of applicable
code;
<script language="javascript">

function toggleDiv( showDiv, hideDiv, showTab)
{
document.getElementById(showDiv).style.display = '';
document.getElementById(hideDiv).style.display = 'none';
document.getElementById("newsTD").background =
'/Images/Banner/240_t_tab_' + showTab + '.gif'
}

function openWindow(filename, name, width, height)
{
windowops =
eval("'toolbar=no,location=no,directories=no,statu s=no,menubar=no,scrollbars=no,resizable=no,width="
+ width + ",height=" + height + "'");
var newWindow = window.open(filename, name, windowops);
newWindow.focus();
newWindow = '';
return;
}
</script>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<!-- News listing -->
<td rowspan="2" align="right" valign="top" width="253"><br>
<table border="0" cellpadding="0" cellspacing="0"
width="240">
<tr>
<td align="center">
<%= w3ss.putField("addBannerLink2") %><br>
<%= w3ss.putField("catalogLink") %> <br>
</td>
</tr>
<tr>
<td id="newsTD"
background="/Images/Banner/240_t_tab_1.gif" width="100%" height="17">
<table border="0" cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td width="120" style="cursor:hand;"
onclick="javascript:toggleDiv( 'memberNews', 'intheNews', '1' );"><img
border="0" src="/Images/Banner/1x1_transp.gif" width="5"
height="1"><span class="menuTab"><%= w3ss.putField("newsCaption")
%></span</td>
<td width="120" style="cursor:hand;"
onclick="javascript:toggleDiv( 'intheNews', 'memberNews', '2' );"><img
border="0" src="/Images/Banner/1x1_transp.gif" width="5"
height="1"><span class="menuTab"><%= w3ss.putField("inthenewsCaption")
%></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%"
background="/Images/Banner/240_m_tab.gif"><ul>
<div id="membernews" class="ingress">
<br>
<%=
ficpa.renderNewsList(Document.Fields("memberNewsFo lders"), "title", "",
"", false, Document.Fields("maxMemNewsItem"), "publishTime", false ) %>
<br>
<img src=/images/banner/bul.gif
border=0>&nbsp;&nbsp;<a href="<%=ficpa.siteURL()%>Top_Stories">Recent
top stories</a>

</div>
<div id="inthenews" style="display:none;"
class="ingress">
<br>

Jul 23 '05 #1
2 7403
"Cy" <we******@gmail.com> wrote:
onclick="javascript:toggleDiv( 'memberNews', 'intheNews', '1' );"><img <div id="membernews" class="ingress">


id is case-sensitive.
Jul 23 '05 #2
On 8 Dec 2004 14:54:20 -0800, Cy <we******@gmail.com> wrote:
Hi, I have a menu that toggles correctly in IE [...]
It shouldn't.
The FireFox JavaScript Console is returning the following error; Error:
document.getElementById(showDiv) has no properties.
The value of an id attribute should be treated as case-sensitive. When you
call the script, you're looking for 'memberNews' and 'intheNews', however
the actual ids are 'membernews' and 'inthenews'. Change one or the other.

[snip]

Some other comments...
<script language="javascript">
The language attribute has been deprecated for over six years. Use the
type attribute instead:

<script type="text/javascript">
function toggleDiv( showDiv, hideDiv, showTab)
{
document.getElementById(showDiv).style.display = '';
document.getElementById(hideDiv).style.display = 'none';
You should test for browser support before use DOM properties and methods.
One simple alternative is:

if(!document.getElementById) {
document.getElementById = function() {return null;};
}

function setStyle(element, property, value) {
element = document.getElementById(element);
if(element.style) {element.style[property] = value;}
}

then:

setStyle(showDiv, 'display', '');
setStyle(hideDiv, 'display', 'none');
document.getElementById("newsTD").background
The background property/attribute is deprecated, as is much of the mark-up
you've shown in this post. All modern documents on the Web should written
to the Strict DTD. Transitional HTML was only meant to be used for a
limited time, and that time has passed (in my opinion, at least).
= '/Images/Banner/240_t_tab_' + showTab + '.gif'
}
The same effect could be achieved with:

setStyle('newsTD', 'backgroundImage',
'url(/Images/Banner/240_t_tab_' + showTab + '.gif)');
function openWindow(filename, name, width, height)
Opening new windows is becoming a very bad idea on the Web. There are many
pop-up blockers that do not discriminate between requested and unrequested
pop-ups, and many users dislike them either way.
{
windowops = eval("'toolbar=no,location=no,directories=no,statu s=no,'
+ menubar=no,scrollbars=no,resizable=no,width=" + width
+ ",height=" + height + "'");
The eval call isn't needed. The feature string could also be *much*
shorter. However, removing window chrome - particularly the scrollbars and
status bar - and attempting to prevent resizing is a bad idea. At a
minimum, it should be:

var features = 'status,scrollbars,resizable,width=' + width
+ ',height=' + height;

Unspecified features (with a couple of exceptions) will be disabled by
default.
var newWindow = window.open(filename, name, windowops);
newWindow.focus();
newWindow = '';
That's unnecessary: when the function returns, local variables are
destroyed[1].
return;
That's unnecessary, too.

[snip]
<%= w3ss.putField("addBannerLink2") %><br>
<%= w3ss.putField("catalogLink") %> <br>
There's not really much point including server-side code unless you have a
Javascript-related question about it.

[snip]
<td width="120" style="cursor:hand;"
The correct property value is 'pointer'.
onclick="javascript:toggleDiv( 'memberNews', 'intheNews', '1' );">


The majority of user agents will just see javascript: as a label. Unless
you're also using client-side VBScript (which is a bad idea, anyway), even
IE will ignore it.

[snip]

Mike
[1] Unless a closure is involved, which it isn't.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

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

Similar topics

12
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can...
5
by: LRW | last post by:
(Sorry if this is a repost...my newsreader keeps crashing on the posting--I don't know if the message going out or not) For some reason this javascript just won't work in Firefox. It works fine...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
23
by: ivan | last post by:
AJAX is a stupid and confusing word. People is wondering for something that programmers have used for many years. Javascript + Xml and asynchronous requests is not new. People started to speak...
5
by: Roger Withnell | last post by:
This is a framed webpage with the navigation bar in "NavBar" and the main window in "Main". When opening a new page in "Main" from "NavBar" with: function OpenFrameWindow(src) { var...
13
by: John Smith | last post by:
I am using IE 6.0 from http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html I gather that "If you need to test a number of command lines, you can reduce the keystrokes by...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
11
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.