Pregunta

I am using a Rich Textbox Plugin called FreeTextBox Demo Link for my ASP.NET Project and I am in need for some javascript code to clear its text on client side.

I have tried using

///------Javascript Code
function clean_designEditor()
{
    var bodyTextBox = document.getElementById("ctl00_cphContent_ftbMailBody_designEditor");
    frameDoc = bodyTextBox.contentDocument || bodyTextBox.contentWindow.document;
    frameDoc.documentElement.innerHTML = "";
}

///------ASP.NET Code
<asp:Button ID="btnPnlCloseMail" runat="server" Text="X" ToolTip="Close" onclick="btnPnlCloseMail_Click" OnClientClick="clean_designEditor();" />

It works as required, but in turn causes some javascript error to occur, thus making other AJAX and Javascript functions to break. I can't mention the error as I am unable to get any, on the console window of Firebug or any other developer tool. And my page has a number of AJAX requesting controls and other Javascript functions, and I guess that this action is causing any issue because when I comment this above mentioned javascript lines, all the things work fine.

Can anyone suggest other way, so that it does not cause any breakdown.

I guess it is kind of a bug as my issue is quite similar to the post FreeTextBox javascript error is preventing PostBack on my DropDownList

In my case, it prevents my dropdown list to postback when I call clean_designEditor() function, otherwise it works ok. Mine is also related to AJAX popup control and Preventing Postback and other AJAX/Javascript request.

¿Fue útil?

Solución

You would have to use below code

// Through id of iframe

var iframe = frames["MyFrame"];

if(iframe.contentDocument) { doc = iframe.contentDocument; } else { doc = iframe.contentWindow.document; }

doc.body.innerHTML = '';

Happy Coding !!!

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top