I am new to Javascript programming, and this person has clearly βcleared me upβ: (........
The following code fragment selects some text by searching and modifying the corresponding text nodes. Node text search is performed using jQuery functionality:
window.addEventListener ("load", highlightSummarySentences, false);
function highlightSummarySentences() { var docName = thisPage; var numSentences = getCookie(docName+"Num"); var linkSentenceNum = getCookie(docName + 'LinkingSentence'); for(var i=0; i<numSentences; i++) { var matchMe = getCookie(docName+i); try { if (matchMe && i==(linkSentenceNum)) { highlightText(matchMe, clickedSentenceColour); } else if(matchMe){ highlightText(matchMe, summarySentenceColour); } } catch (e) {; } } }
The for loop starts once and selects the corresponding text, after which it exits, and the page turns completely white. The following error is displayed in the error console:
Error: getCookie not defined
but I think this is not getCookie. The script simply refuses to recognize any function or variable after the above event. I have no idea what might make a script behave this way. I am developing in firefox.
Please give me a hint! Let me know if I should insert more code for more information.
Thanks,
source share