PDA

View Full Version : Can anyone help with a script that's crashing IE


Mark One
10-09-2005, 01:21 AM
Guys,

Would really appreciate some help here from anyone in the know.

I am hosting an online bible. Problem is, the chapter & verse entries are added using a document.write script that is fine in Firefox but is crashing IE.

The script is simple but I can't for the life of me work out what's going wrong (I'm a humble coder with little knowledge of JS).

Can anyone give me a clue as to what's going wrong or even better post a fix? The alternative is to go through thousands of lines of code updating them manually & much as I am happy to host the Bible for a friend, life is too short.

Many, many thanks to anyone who can help me out here.


Here's the offending script -

HTML page code:

In the header a link to external JS file:

----------------------------------------

<script src="web.js" type="text/javascript"></script>

----------------------------------------

In the page body the script that writes the appropriate chapter & verse:

----------------------------------------

<script type="text/javascript">cb(1,1);</script>In the beginning God
created the heaven and the earth. <script
type="text/javascript">cb(1,2);</script>And the earth was without form etc. etc.

----------------------------------------

In the external file web.js:

----------------------------------------

function cb(chapter, verse)
{ /* Write a chapter-verse marker */
document.write("</span> <a name=\"C"+chapter+"V"+verse+"\" class=\"cv\">"+chapter+":"+verse+"</a> <span class=\"b\">");
}

----------------------------------------

Philip M
10-09-2005, 08:42 AM
You have used double quotes throughout and there is one " missing. Change to:-

function cb(chapter, verse)
{ /* Write a chapter-verse marker */
document.write('</span> <a name=\"C"+chapter+"V"+verse+"\" class=\"cv\">"+chapter+":"+verse+"</a>" <span class=\"b\">');
}

Mark One
10-09-2005, 02:22 PM
Thanks for this Philip - unfortunately it doesn't seem to work.

Using your ammended code the string "+chapter+":"+verse+"" renders on the page instead of the respective chapter & verse:

Should display:

1:1 Adam, Sheth, Enosh, 1:2 Kenan, Mahalaleel, Jered, 1:3 Henoch, Methuselah, Lamech

Instead displays

"+chapter+":"+verse+"" Adam, Sheth, Enosh, "+chapter+":"+verse+"" Kenan, Mahalaleel, Jered, "+chapter+":"+verse+"" Henoch, Methuselah, Lamech

And IE still crashes :(

Any other thoughts?

Many Thanks,

Mark

Mark One
10-09-2005, 05:34 PM
:confused: :(

_Aerospace_Eng_
10-09-2005, 06:25 PM
Try
function cb(chapter, verse)
{ // Write a chapter-verse marker
document.write('</span> <a name="C'+chapter+'V'+verse+'" class="cv">'+chapter+':'+verse+'</a>" <span class="b">');
}

Mark One
10-09-2005, 10:27 PM
Thanks Aero - but still no go...

This renders as:

1:1" Adam, Sheth, Enosh, 1:2" Kenan, Mahalaleel, Jered

note the extra " after the verse number. And IE (6.0.2900.2180) still crashes.

This is driving me nuts.

Any other suggestions?

Thanks again,

M

Mark One
10-09-2005, 10:38 PM
OK - problem doesn't seem to by JS after all.

Original script works fine when I remove this line from the css file:

a.cv {font-size: smaller; color: blue; vertical-align: top}

More specifically the "vertical-align: top" element seems to be causing all the trouble. Though why I don't know.

Thanks for trying guys - if you have any suggestions as to why this css element together with the JS is crashing IE I'd be very grateful.

M