Quote:
Originally Posted by paulsm4
Hi -
1. Semicolons are good:
Code:
var rbar = documentgetElementByID('r_sidebar');
2. The test is too complex:
Code:
// Poor
if (rbar != r_sidebar) {
}else{
curvyCorners(setting, ".r_sidebar");
}
// Better
if (rbar == r_sidebar)
curvyCorners(setting, ".r_sidebar");
3. You're not correctly testing for (the very real case!) "object not found":
Code:
if ( (rbar) && (rbar == r_sidebar) )
curvyCorners(setting, ".r_sidebar");
'Hope that helps .. PSM
PS:
Strong recommendation:
Install Firefox (if you haven't already) and install the Firebug debugger. It's totally indispensable!
|
Paul-
I actually have tested it with semicolons - I forgot to put em back when I tested the method above again LOL..
I do alot of PHP coding and javascript is similar to it but it seems there are some differences I just have not learned yet
Im trying to expand my Javascript skills a bit lol
I had tried all the methods you showed me except the last one the
" testing for (the very real case!) "object not found":"
so ill give that a whirl.
thanks for the input
p.s. I have FireFox Just dont use it often and forgot totally about FireBug!!! (smacks self in head)
did not work !!! arg.
ok let me further explain this
I have say 2 pages
page 1 contains all the div ids that are listed in the javascript function for roundcorners
page 2 DOES NOT have division id contentleft, r_sidebar, l_sidebar, blah blah
HOW can I tell the javascript to CHECK if the div id exists BEFORE assign ing the settings to the roundcorners function?
because as it is now whenever a user travels to a page that does not contain the divisions it throws an error alert up! and well I cant have that lol