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

How do I make this function netscape/firefox friendly?

Can anyone help me; this code works perfectly in IE but not in NN or
Firefox.

function fDHTMLPopulateFields(displayValuesArray, displayOrderArray){
for(i=0; i<displayValuesArray.length; i++){
displayFieldName = "div_" + displayOrderArray[i] + "ID"
document.all[displayFieldName].innerText = displayValuesArray[i]
}
}

Thanks in advance.

Jul 23 '05 #1
3 1185
ef*****@epitome.com.sg wrote:
Can anyone help me; this code works perfectly in IE but not in NN or
Firefox.


Untested quick hack:

function fDHTMLPopulateFields(displayValuesArray, displayOrderArray) {
var i,
currentElement,
displayFieldID,
currentChild,
nDisplayValues = displayValuesArray.length;
for (i=0; i<nDisplayValues; i++) {
displayFieldID = "div_" + displayOrderArray[i] + "ID";
currentElement = (document.getElementById
&& document.getElementById(displayFieldID))
|| (document.all
&& document.all(displayFieldID));
if (typeof currentElement == "object") {
if (typeof currentElement.innerText != "undefined") {
currentElement.innerText = displayValuesArray[i];
}
else if (currentElement.firstChild
&& currentElement.removeChild
&& currentElement.appendChild
&& document.createTextNode
) {
while ((currentChild = currentElement.firstChild)) {
currentElement.removeChild(currentChild);
}
currentElement.appendChild(
document.createTextNode(displayValuesArray[i])
);
}
}
}

ciao, dhgm
Jul 23 '05 #2
Dietmar

Thanks. I'll test it and tell you if it works :)

Jul 23 '05 #3

ef*****@epitome.com.sg wrote:
Can anyone help me; this code works perfectly in IE but not in NN or
Firefox.

function fDHTMLPopulateFields(displayValuesArray, displayOrderArray){ for(i=0; i<displayValuesArray.length; i++){
displayFieldName = "div_" + displayOrderArray[i] + "ID"
document.all[displayFieldName].innerText = displayValuesArray[i]
}
}

Thanks in advance.


the code is using "document.all", which was invented by microsoft,
works only in their browsers (though i read ff has an "invisible
support" for that, but i never tested) and is not conform to standards.
try to avoid it.

use for instance document.getElementById("id") to access elements

micha

Jul 23 '05 #4

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

Similar topics

5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
5
by: danny.myint | last post by:
I was under the assumption that javascript loads all the <head></head> elements before processing the <body> tag in Mozilla/Netscape/Firefox. It doesn't seem like it, with my problem. I have...
1
by: RC | last post by:
I know DTD (Document Type Definition) is supported by Netscape/Firefox and IE. But I typed some examples from http://www.w3schools.com/schema/default.asp Seems no effect on those browsers.
6
by: qqq | last post by:
I'm a relative newbie... I'd like my site to support Netscape browsers. For a page I set 'TargetSchema' to 'IE 3.02/Netscape 3'. When I insert label or textbox web controls on the page, they...
15
by: Viken Karaguesian | last post by:
Hello all, Just a curiosity question here. Since Firefox and Netscape are both based on the Mozilla engine (AFAIK), can I assume that they will display my pages the same way? Viken K. --
10
by: News | last post by:
I have a page up trying to learn how to ID a browser and other info. http://wyght.com/warren/testPos.html here is the code <script type = "text/javascript"> var space = ", "; var name...
6
by: Nightshade | last post by:
I have an HTML form using JavaScript that seems to function properly in IE but not in Mozilla Firefox 1.5 or in Netscape 8.1 (based on Firefox). The error in Firefox/Netscape is "testForIt() not...
7
by: Dayo | last post by:
Hello folks. Sorry if this seems a bit silly, I have no experience with this type of code. Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not...
4
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
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
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?
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
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
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
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
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...

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.