954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Javascript and Firefox ISSUES

My javascript code works in IE but not in Firefox. Is there anyone that can help with this. If so, I can post my script and see where the problem is. I haven't used javascript for long so my experience with it is limited. Cannot figure out what it is on my own. Need Help!

bturner
Newbie Poster
7 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

Firefox itself will help. Use the "JavaScript Console" under the Tools menu to see the errors.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

tgreer - Thanks for that. I am going to try that and see if it fixes my issues.
thx again

bturner
Newbie Poster
7 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

Using the javascript console gave me the error that I have been getting but it didn't help any further than that. Should I post my script to see to see if there are errors in it or why it isn't working?

bturner
Newbie Poster
7 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

Why not post the error, first?

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

function _TF_trimWhitespace(txt) {
var strTmp = txt;
//trimming from the front
for (counter=0; counter=0; counter--)
if (strTmp.charAt(counter) != " ")
break;
return strTmp.substring(0, counter+1);
}

function _TF_showAll(tb) {
for (i=0;i 0) //has selected items
{
index = conditions.length;
conditions[index] = new Object;
conditions[index].name = inputs[i].getAttribute("TF_colKey");
conditions[index].type = inputs[i].getAttribute("TF_searchType");
conditions[index].value = optsSelected;
conditions[index].single = false;
}
}
//ok, now that we have all the conditions, lets do the filtering proper
_TF_filterTable(tb, conditions);
}

function TF_enableFilter(tb, frm, val) {
if (val.checked) //filtering is on
{
frm.style.display = "";
} else { //filtering is off
frm.style.display = "none";
}
//refresh the table
TF_filterTable(tb, frm);
}

function _TF_get_value(input) {
switch (input.type)
{
case "text":
return input.value;
break
case "select-one":
if (input.selectedIndex > -1) //has value
return input.options(input.selectedIndex).value;
else
return "";
break;
}
}

//util function that concat two input fields and set the result in the third
function TF_concat_and_set(salText, salSelect, salHidden) {
var valLeft = _TF_get_value(salText);
var valRight = _TF_get_value(salSelect);
salHidden.value = valLeft + valRight;
}

bturner
Newbie Poster
7 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

Here is the error that I keep getting. The page opens but it won't work from there.

"A script on this page may be busy, or it may have stopped responding. you can stop the script now, or you can continue to see if the script will complete."

Either way it never completes. If I stop it or continue. The code I submitted is used as an include in my page.

I am new to all of this so bear with me. Sorry for any stupid questions. :cheesy:

bturner
Newbie Poster
7 posts since Mar 2006
Reputation Points: 10
Solved Threads: 0
 

That's a lot of code to debug... forgive me for not being more helpful, but if you're new at this, then how did you write all this code? If you DIDN'T write the code, then perhaps you'd get better support from whomever did?

If I have time this weekend, I may take a closer look.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 

That's a lot of code to debug... forgive me for not being more helpful, but if you're new at this, then how did you write all this code? If you DIDN'T write the code, then perhaps you'd get better support from whomever did?

If I have time this weekend, I may take a closer look.

tgreer,
I believe the author of the code is Sidney Chong. Here is a link to the demo for this code called "TableFilter". http://www.codeproject.com/jscript/tablefilter.asp?df=100&forumid=2552&exp=0&select=894102

In the post the author states:
"Browser Compatibility This script and the demo were developed and tested on the IE platform only, since the project did not require Netscape compatibility. It shouldn't be too difficult to make it work on Netscape and I'll probably get round to it when I have the time. I would appreciate any help in this area as well."

Plus there are some posts that seems to indicate that Firefox compatibility has not been figured out yet.

Using Firebug it appears the this line
var inputs = frm.tags("INPUT");
is an issue for Firefox. It registers the error "Element referenced by ID/NAME in the global scope. Use W3C standard document.getElementById() instead."

However it looks like IE can reference form fields by "TYPE".

Is there an equivalent Firefox call or would the code need to be restructured to pass the names of the form fields that need to be processed?

thanks,
John

jswindell
Newbie Poster
2 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

You can use the cross-browser DOM method " getElementsByTagName ".

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 
You can use the cross-browser DOM method " getElementsByTagName ".

Excellent thanks for the quick response! After I posted my question I sort of stumbled ("Googled" ) on that method by accident. Is there something I can read that is a good primer on the DOM model?

FWIW I used Firebug to debug the tablefilter code and will be posting the details on the originating site. It turns out that fix and one other change ,replace = .innerText references to = .innerHTML, got the code working perfectly.

thanks again,
John

jswindell
Newbie Poster
2 posts since May 2006
Reputation Points: 10
Solved Threads: 0
 

The World Wide Web Consortium maintains all the standards and documentation.

tgreer
Made Her Cry
Team Colleague
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
 
Excellent thanks for the quick response! After I posted my question I sort of stumbled ("Googled" ) on that method by accident. Is there something I can read that is a good primer on the DOM model?



A good source of documentation would be at www.w3schools.com . They have a full tutorial on HTML DOM. It would be best to start there coz u can test out the tutorials on the site itself. I'm also starting to learn web programming myself and I find resources there to be most useful

jblacdao
Light Poster
37 posts since Jan 2007
Reputation Points: 12
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You