Forum Moderators: open

Message Too Old, No Replies

probable javascript error, but can't find

I can't view my page in IE, and think it's a javascript error

         

quartney

8:20 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



[cofc.edu...]

I have the phrase "lorem ipsum" in the CSS div id "cecil" on my page. It should be outside the control of any javascript. However, I am unable to see the phrase in IE (see it fine in Firefox and Mozilla), and I'm guessing it has something to do with my javascript (because when I delete the code/html for the javascript menu bar, I can see "lorem ipsum.") Otherwise, IE gives me an "error on page" message.

I'm a javascript dummy, so I really need any help you can provide!

thanks,
Courtney

icpooreman

8:44 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



well putting semicolons after statements would help. None of your JavaScript statements have a semicolon after them you need that after things like var i=0 so have var i=0;

After you do that then see if it works and if it doesn't keep trying to fix all the syntax errors for a while.

kaled

7:21 pm on Jul 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not certain but I think semicolons are optional before linebreaks.

Kaled.

Iguana

7:38 pm on Jul 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



error on line 73 - Object Required
The line is: document.getElementById(cid).style.display="block"

The element cid is passed in to the function from this line:
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
when loading - it's trying to set up the initial tab.

There is a call to the Home tab in your tablist
onmouseover="expandcontent('sc1', this)
but there is no div with the id="sc1"

define a Home "sc1" div and you should be ok.

quartney

1:25 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



thanks for your input! Unfortunately, putting a div for sc1 didn't seem to work. I did try putting in some semicolons after any var statements as suggested, but that didn't change anything. I didn't put in more semicolons because, as I said, I'm a javascript dummy and I'm not sure where the semicolons should and shouldn't go. :/

So now, the page has the sc1 div and no added semicolons.

Any other suggestions?

thank you,
Courtney

kaled

4:53 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can change IE options to give a more detailed error message for javascript. That might tell you something.

Kaled.

quartney

2:55 pm on Jul 6, 2005 (gmt 0)

10+ Year Member



now I don't get an error message ... but I still can't see the text "lorem ipsum". Can anyone else see the text or get an error message?

quartney

6:25 pm on Jul 6, 2005 (gmt 0)

10+ Year Member



Okay, I'm deconstructing my code. On the page:
[cofc.edu...]

I get this error:

Line 73, Char: 1
error: object required
code: 0

and here is the javascript on line 73:
document.getElementById(cid).style.display="block"

here is the block of javascript surrounding line 73:

function expandcontent(cid, aobject){
if (disabletablinks==1)
aobject.onclick=new Function("return false")
if (document.getElementById){
highlighttab(aobject)
if (turntosingle==0){
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
}
}
}

any idea on what's wrong with line 73?

kaled

11:30 pm on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When using getElementById() it is a good idea to break down the code into parts.

var e = document.getElementById(id);
if (e) e.style.display = ''; else alert(id + ' not found.');

Obviously, you should remove the alert part when the code is working properly.

Kaled.