...

View Full Version : Unkown Javascript error



enderwiggin7
07-16-2009, 08:13 PM
addMainItem('index.html';'::Home';mwidth;'center';'';'';0;0;'');

The above line of code in my navbar is crapping at me for having bad syntax, something about lacking a closing brace. Clearly, I have a closing brace. Any ideas?

ckeyrouz
07-16-2009, 08:17 PM
I think the separator between the parameters passed inside the function should b "," and not ";"

enderwiggin7
07-16-2009, 08:41 PM
See, that's what I thought - but then I was checking out help sites, and they said use ";"

...and that still doesn't explain the ")" error.

:(

ckeyrouz
07-16-2009, 08:46 PM
Post code please to take a deeper look.

enderwiggin7
07-16-2009, 08:48 PM
www.bebetterdomore.com/custom.js

line 121

VIPStephan
07-16-2009, 08:48 PM
See, that's what I thought - but then I was checking out help sites, and they said use ";"

...and that still doesn't explain the ")" error.

:(

Really, this canít be semicolons, it must be commas. What are these help sites that tell you this?

enderwiggin7
07-16-2009, 08:57 PM
I closed the other link, but here is one of them (http://javascript.about.com/od/reference/a/error_3.htm). I could have misread it - I'm still pretty new to Javascript... programming in general, really.

I haven't had a chance to implement your CSS bar just yet - I will be very soon. The current Javascript bar seems to be working fine now on most computers, just not a few. The error seems to focus on that one line, which is the only section that doesn't load properly.

ckeyrouz
07-16-2009, 08:57 PM
I saw in the site you have mentioned:
addMainItem("index.html","::Home",mwidth,"center","","",0,0,"");

so there are no ; only ,

My question is are you sure you did not miss any import of a js file where the method addMainItem is defined?

Otherwise post your code not the code of the web site you got your source from.

enderwiggin7
07-16-2009, 09:00 PM
My question is are you sure you did not miss any import of a js file where the method addMainItem is defined?

Um, not really sure what you mean by this, sorry.

I never uploaded the code with semicolons to the site, but the rest of the code is the same. Now that VIPStephan assures me that they shouldn't be there, I won't be.

enderwiggin7
07-16-2009, 09:02 PM
Update: the semicolons were replaced with commas, and uploaded to the site, and now my navbar has disappeared entirely. o.O

tomws
07-16-2009, 09:14 PM
Use Firefox with Firebug. Quickly identifies javascript errors. Assuming your site is at http://www.bebetterdomore.com/, you have these errors:

missing variable name
http://www.bebetterdomore.com/custom.js
Line 29

bSIZE is not defined
http://www.bebetterdomore.com/style.js
Line 12

baseHREF is not defined
http://www.bebetterdomore.com/menu.js
Line 4

tomws
07-16-2009, 09:16 PM
Now that I look at the code, I see the problem. VIPStephan didn't say to replace ALL semicolons on your site with commas. Use commas in function calls to separate the arguments. Use semicolons as line terminators.

enderwiggin7
07-16-2009, 09:18 PM
I have FireBug - how do I use it to view Javascript errors? I can only see HTML.

Also, how do I define those two variables? Could they be causing the error that causes my nabar to work sometimes but not others?

enderwiggin7
07-16-2009, 09:19 PM
Now that I look at the code, I see the problem. VIPStephan didn't say to replace ALL semicolons on your site with commas. Use commas in function calls to separate the arguments. Use semicolons as line terminators.

Aha! Okay, I'll go and convert those now. Thank you!

tomws
07-16-2009, 09:25 PM
I have FireBug - how do I use it to view Javascript errors? I can only see HTML.

Open the Firebug panel. Click on something like the Script tab. You should see text similar to "XYZ panel is disabled." Click all of the checkboxes and click the Apply Settings button. Welcome to a whole new world of debugging. Celebrate with pizza.

enderwiggin7
07-16-2009, 09:27 PM
Okay - FireBug is showing me Javascript now - thank you!

I've uploaded a revised custom.js, but the navbar still does not appear.

tomws
07-16-2009, 09:29 PM
Missed a comma at the end of line 29.

enderwiggin7
07-16-2009, 09:33 PM
I posted, but nothing happened, so here I try again:

Thanks for the FireBug help - that's working great now.

I've uploaded a new custom.js with the semicolon changes, but it still isn't showing up...

enderwiggin7
07-16-2009, 09:34 PM
Comma fixed. Still no navbar... (thanks for checking)

tomws
07-16-2009, 09:45 PM
Check line 29 again. No value before the semicolon.

These basic errors are causing the rest of the js to fail, so the nav won't show. Once you get those fixed, you should be good to go.

enderwiggin7
07-16-2009, 09:53 PM
Sidethought1: (The link in your siggy is hilarious! haha :thumbsup: )
Sidethought2: (Just noticed the lame n00b spelling in my subject - sorry 'bout that)

<hr>

Absolute left value added. *duh* - must have deleted than when replacing the commas. Thanks.

<hr>

FireBug doesn't seem to be showing any errors for me. Is there a setting that has to be turned on to do that?

tomws
07-16-2009, 09:57 PM
Mine shows notices besides the bug icon. Clicking there opens the Firebug console where I get error details... like the one that shows line 111 terminated with a comma instead of semicolon, too.

enderwiggin7
07-16-2009, 10:02 PM
That did it for the navbar's disappearing act! Now just one issue - the first navbar link, "Home" appearing at the bottom of the screen, leaving an empty white box where it ought to be. FireBug is directing me to a section of code, but I don't see errors beside the icon as you describe. (Thanks so much for your help - I hope we can get this last error finished so I can move past this error. It's been plaguing me for weeks.)

VIPStephan
07-16-2009, 10:09 PM
VIPStephan didn't say to replace ALL semicolons on your site with commas.

That is because at that time I didn’t know ALL of the code.

And I remember that site now.
Now, the home link not appearing in the right spot is because that table (a table for one button??) isn’t inside a division as all the other buttons. Just compare the code.

That’s why I recreated this menu using a list and CSS.

enderwiggin7
07-16-2009, 10:16 PM
VIPStephan - as I said, I will be implementing that soon - but I need to get this one working today.

I don't see table tags around it - could you show me where you found those, please? As I said in the other thread - I didn't design this, I'm just the one who has to clean it up...

enderwiggin7
07-16-2009, 10:26 PM
Specifically - what's the fastest, simplest way to drop it into the same table as the other links, so they always act the same?

VIPStephan
07-16-2009, 10:47 PM
Well, the thing is the entire menu seems to be generated through JS as I can only see the menu items in Firebug (or by viewing the generated source through the web developer toolbar). And there I see that all menu items are inside a div with ID “maincell” plus a number except the home link.

Now, I suppose this is because of some nesting error (unclosed element) but this can only be found out if you fix the other errors one by one because currently it’s just a real mess.

Apply a transitional HTML doctype (<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">), run your site through the validator (http://validator.w3.org), and fix the errors, then we’ll get closer to it, I promise.

enderwiggin7
07-16-2009, 10:54 PM
Okay, thank you - I have to go now, but I'm going to take care of this first thing either Monday or Tuesday. Thanks again for your help! I can't wait to be done with this...

enderwiggin7
07-20-2009, 07:17 PM
okay - doctype declared, all errors fixed (but one, "Error Line 105, Column 11: Attribute "COLOR" is not a valid attribute. Did you mean "color"?" which looks fine to me...)

The navbar is looking perfect on first load, but disappears as black and white boxes when you hover over them. What's our final step to make this puppy work?

Thanks!

enderwiggin7
07-20-2009, 10:57 PM
alright... I need to put my index back the way it was, so its now located at http://www.bebetterdomore.com/index4.html

Thanks.

enderwiggin7
07-21-2009, 02:25 PM
Update: Found and ran JSlint on custom.js, fixed all errors but this one, which I don't understand:


Error:

Implied global: addChildmenuItem 165 166 167 168 169 170 175 177 178 179 180 182 183 184 186 187 188 189 191 192 193 205 206 207 208 209 210 211 212, addMainItem 121 123 136 149 197 215 217, addSubmenuItem 127 128 129 130 140 141 142 143 144 145 153 154 157 199 200 201 202 219 220 221, defineChildmenuProperties 160 204, defineSubmenuProperties 125 138 151 198 218, exclude 3

(Off-topic question - why can't I add an avatar? It has the radio button fixed on "none". Is there a minimum post count or something?)

enderwiggin7
07-21-2009, 02:30 PM
I ran the same check on style.js, who's function is unknown to me, and got a basket-full of errors:


Error:

Implied global: aDEC 17, aLINK 17 18, allowRESIZE 14, bSIZE 12, cellCLICK 12, document 8, exclude 6, fFONT 17, fSIZE 10 12 17, fWEIGHT 12 17 18, mac 10, menuALIGN 14, mu 12, ns4 10 17, op5 10, remoteTRIGGERING 14, saDEC 17, saLINK 17, sbSIZE 12, sfFONT 17, sfSIZE 10 12 17, sfWEIGHT 12 17, shSIZE 12, stINDENT 12, staticMENU 14, svPADDING 12, tINDENT 12, vPADDING 12
Problem at line 12 character 12: Expected '{' and instead saw 'bSIZE'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 31: Expected '{' and instead saw 'fSIZE'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 52: Expected '{' and instead saw 'tINDENT'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 76: Expected '{' and instead saw 'vPADDING'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 99: Expected '{' and instead saw 'sbSIZE'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 121: Expected '{' and instead saw 'sfSIZE'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
Problem at line 12 character 144: Expected '{' and instead saw 'stINDENT'.
if(bSIZE<0)bSIZE=0;if(fSIZE<5)fSIZE=5;if(tINDENT<0)tINDENT=0;if(vPADDING<0)vP...
~
Problem at line 18 character 143: Bad escapement.
else{stySTR+='<style><!--';stySTR+='.mTD,.mTD A \{white-space:nowrap;color:'+...
Problem at line 18 character 160: Bad escapement.
else{stySTR+='<style><!--';stySTR+='.mTD,.mTD A \{white-space:nowrap;color:'+...
Problem at line 18 character 160: Too many errors. (30% scanned).

VIPStephan
07-21-2009, 02:34 PM
I tell you: You could have it all working by now if you implemented the CSS menu I provided. In the time you’re wasting on fixing an outdated script you could have converted the entire site into a semantic CSS layout at least three times.

As to the Avatar: http://codingforums.com/showpost.php?p=745018&postcount=1

enderwiggin7
07-21-2009, 02:40 PM
It's out of my hands - I've been asked to get THIS one working. All I need is for the navbar to appear properly and not move around or disappear on me. I care about nothing else in this. It doesn't need to be fancy or clean, it just needs to work.

enderwiggin7
07-21-2009, 03:27 PM
apply a transitional html doctype, run your site through the validator, and fix the errors, then we’ll get closer to it, i promise.

. . .



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum