Hi,
our application is in asp.net 2.0,and i have added spell check to the fckeditor that we are using with it...however the spellcheck is working fine on the development machine...its not working when the application runs on the server....i am using javascript for spell check....it gives error "object doesnot support this property or method".plz help me in solving it....
thanks in advance.
my js code is:

// spell checker constants
var spellURL = "SpellCheck.aspx";
var showCompleteAlert = true;


var tagGroup = new Array("INPUT", "TEXTAREA", "DIV", "SPAN");
// global elements to check
var checkElements = new Array();

function getText(index)
{
    var oElement = document.getElementById(checkElements[index]);
    //alert(' this is ' + oElement)
    var sText = "";


    switch (oElement.tagName)
    {

        case "INPUT" :
        case "TEXTAREA" :
            sText = oElement.value;
            break;
        case "DIV" :
        case "SPAN" :
        case "BODY" :
            sText = oElement.innerHTML;
            break;
        case "IFRAME" :
            var oFrame = eval(oElement.id);
            sText = oFrame.document.body.innerHTML;
    }
    //alert('this is' + sText);
    return sText;

}

function setText(index, text)
{
    var oElement = document.getElementById(checkElements[index]);

    switch (oElement.tagName)
    {
        case "INPUT" :
        case "TEXTAREA" :
            oElement.value = text;
            break;
        case "DIV" :
        case "SPAN" :
            oElement.innerHTML = text;
            break;
        case "IFRAME" :
            var oFrame = eval(oElement.id);
            oFrame.document.body.innerHTML = text;
            break;
    }
}

function checkSpelling()
{
    checkElements = new Array();
    //loop through all tag groups
    for (var i = 0; i < tagGroup.length; i++)
    {
        var sTagName = tagGroup[i];
        var oElements = document.getElementsByTagName(sTagName);
        //loop through all elements
        for(var x = 0; x < oElements.length; x++)
        {
            if ((sTagName == "INPUT" && oElements[x].type == "text") || sTagName == "TEXTAREA")
                checkElements[checkElements.length] = oElements[x].id;
            else if ((sTagName == "DIV" || sTagName == "SPAN") && oElements[x].isContentEditable)
                checkElements[checkElements.length] = oElements[x].id;
        }
    }
    openSpellChecker();
}

function checkSpellingById(id)
{
    checkElements = new Array();
    checkElements[checkElements.length] = id;
    openSpellChecker();
}

function checkElementSpelling(oElement)
{
    checkElements = new Array();
    checkElements[checkElements.length] = oElement.id;
    openSpellChecker();
}

function openSpellChecker()
{
    if (window.showModalDialog)
        var result = window.showModalDialog(spellURL + "?Modal=true", window, "dialogHeight:320px; dialogWidth:400px; edge:Raised; center:Yes; help:No; resizable:No; status:No; scroll:No");
    else
        var newWindow = window.open(spellURL, "newWindow", "height=300,width=400,scrollbars=no,resizable=no,toolbars=no,status=no,menubar=no,location=no");
}


/****************************************************
* Spell Checker Suggestion Window JavaScript Code
****************************************************/
var iElementIndex = -1;
var parentWindow = 0;

function initialize()
{
    iElementIndex = parseInt(document.getElementById("ElementIndex").value);

    if (parent.window.dialogArguments)
        parentWindow = parent.window.dialogArguments;
    else if (top.opener)
        parentWindow = top.opener;

    var spellMode = document.getElementById("SpellMode").value;

    switch (spellMode)
    {
        case "start" :
            //do nothing client side
            break;
        case "suggest" :
            //update text from parent document
            updateText();
            //wait for input
            break;
        case "end" :
            //update text from parent document
            updateText();
            //fall through to default
        default :
            //get text block from parent document
            if(loadText())
                document.SpellingForm.submit();
            else
                endCheck()

            break;
    }
}

function loadText()
{
    if (!parentWindow.document)
        return false;

    // check if there is any text to spell check
    for (++iElementIndex; iElementIndex < parentWindow.checkElements.length; iElementIndex++)
    {
        var newText = parentWindow.getText(iElementIndex);
        if (newText.length > 0)
        {
            updateSettings(newText, 0, iElementIndex, "start");
            document.getElementById("StatusText").innerText = "Spell Checking Text ...";
            return true;
        }
    }

    return false;
}

function updateSettings(currentText, wordIndex, elementIndex, mode)
{
    document.getElementById("CurrentText").value = currentText;
    document.getElementById("WordIndex").value = wordIndex;
    document.getElementById("ElementIndex").value = elementIndex;
    document.getElementById("SpellMode").value = mode;
}

function updateText()
{
    if (!parentWindow.document)
        return false;

    var newText = document.getElementById("CurrentText").value;
    parentWindow.setText(iElementIndex, newText);
}

function endCheck()
{
    if (showCompleteAlert)
        alert("Spell Check Complete");
    closeWindow();
}

function closeWindow()
{
    if (top.opener || parent.window.dialogArguments)
       self.close();
}

function changeWord(oElement)
{
    var k = oElement.selectedIndex;
    oElement.form.ReplacementWord.value = oElement.options[k].value;
}

enable debugging in internet explorer and enter into debug mode when you see the error box. there you can see the line causing the problem. if the object does not support that property or method, it basically does not. it is not an issue of server since the javascript code is executed on the browser of the client machine, so probably your tester browsers are different.

Hi,
thanks for the reply....after debugging i cud find a thing dat...the textarea that i am using, i can see dat its in the source of the page when the page is run..but on the server that textarea is not on the source,which means that the id of the particular textarea is not being passed to the function......how can i deal wid this????


enable debugging in internet explorer and enter into debug mode when you see the error box. there you can see the line causing the problem. if the object does not support that property or method, it basically does not. it is not an issue of server since the javascript code is executed on the browser of the client machine, so probably your tester browsers are different.

ok, probably you are trying to access a server control with its ID, you cant do that because it is changed before rendering, you have to get the ID and put that into javascript variable like this:
var myTextAreaId="<%= textAreaId.ClientID %>";
that will work fine. By the way, it will be better if you use more formal english, please write the words as they are spelled.
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.