View Full Version : Javascript error help

12-15-2006, 02:12 AM
I am using some javascript code that jscheuer1 (sp?) posted a couple months ago. This is the part where I am getting an error:

function compose(){
var addys='', cc='?cc=', boxes = document.getElementById('boxes').getElementsByTagName('input')
for (var i=0; i<boxes.length; i++)
if (boxes[i].checked&&boxes[i].name=='mail')
addys+=boxes[i].value+', ';
else if (boxes[i].checked&&boxes[i].name=='cc')
cc+=boxes[i].value+', ';
addys=addys.replace(/, $/, '');
cc=cc!='?cc='? cc.replace(/, $/, '') : '';
var mailwin=window.open('mailto:'+addys+cc);

I also added some database selection criteria. If I make a selection from the database, I get an error, but it works anyway and pops up the compose box. The error says:
Line: 92
Char: 1
Error: "null" is null or not an object
Code: 0

If I try to pull everything from the database and not filter it, then I get an error and it won't bring up the compose box. The error now says:
Line: 91
Char: 1
Error: Invalid syntax
Code: 0

I show that Line 91 is var mailwin=window.open('mailto:'+addys+cc);

Any idea what the problem is here? Thanks :)

12-15-2006, 04:58 AM
Javascript errors of that sort often refer to the line number before the one reported.

What browser gives these errors and what email client are you using?

12-15-2006, 05:31 AM
I am actually able to see the error in IE6.0, but it does the same thing in Firefox, but it just doesn't work, it doesn't give me the error message. Email client is Outlook Express at work, and I just tried here at home with Thunderbird with the same results.

12-15-2006, 06:12 AM
In FF the error is reported but, unless you have the developer's extension, you need to open up the javascript console to see any evidence of it:

Tools > JavaScript Console

You will often, but not always, get a more precise and accurate error report from FF. Give that a shot as, since I have no idea what is involved with:

added some database selection criteria

Unless you post a link to the page, there is little I can do to help diagnose this. You or I might get a clue from the FF javascript console error(s) but, what we probably really need to see is the source and/or the generated source.

12-15-2006, 06:48 AM
Here is what I got from the FF error console:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMXULElement.boxObject]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://global/content/bindings/tabbrowser.xml :: _notifyBackgroundTab :: line 2867" data: no]

But I get that same thing whether it works or not.

I will PM you the URL info.

12-15-2006, 07:12 AM
Hmm, I am playing with it, and I notice that if I uncheck all and try to send to just one person, or a selection of people, it is working. And that's just the difference in the check box, it wouldn't be a change in the code, so I think the page is probably ok, but maybe it is hitting a limitation or something? I unchecked until it worked, and I think I counted around 80 emails. But then if I turn more on, it doesn't work again.