PDA

View Full Version : setInnerHtml doesnot work in Firefox



easyCodes
01-09-2007, 07:55 AM
Hi does any one knows replacement of setInnerHtml function as it doesnot work in Firfox and gives error.

regards,

Twey
01-09-2007, 08:35 AM
There's no such function in any browser, so far as I (and Google) are aware. You'd set the innerHTML property of the element instead. However, it's not advised to do so -- use DOM methods instead.

easyCodes
01-09-2007, 09:55 AM
May Be!........ Actually i am using online web editor (like we are using for this forum) so using Java Script i am setting some value in editor... method innerhtml i think overwrites each time when function is called i dont want previous contents to be removed i want it to be there n a way from which i can insert my text on the this text Area..... So Basic purpose is just to insert some text on the top of textarea with the previous content present there..

regrads,

easyCodes
01-09-2007, 10:25 AM
i m using code like this
FCK.SetInnerHtml = function( html ) // IE Only
{
var oDoc = FCK.EditorDocument ;

oDoc.body.innerHTML = '<div id="__fakeFCKRemove__">&nbsp;</div>' + html ;
}
Firefox says that SetInnerHtml is not a function but there is no problem in IE... i think there is some problem in function defination.

regards,

Twey
01-09-2007, 06:21 PM
Is the // IE Only comment part of the code, or have you added? If the former, I would suspect that that is your problem. If the latter, I must ask whether you are calling SetInnerHtml() or FCK.SetInnerHtml(). Either way, I would recommend you use DOM methods over innerHTML, dropping said editor if it becomes necessary.

mburt
01-09-2007, 08:17 PM
method innerhtml i think overwrites each time when function is called
Simply do:

oDoc.body.innerHTML += ...
But as Twey said, stick to the DOM methods.

easyCodes
01-10-2007, 10:28 AM
Thank You for Your Support.... Actually Problem stands here.. Please have a look..
this code is not working for me actually i am not a js expert just beginner so need your help to implement this code please check the code below you may have better idea whats going on..


function FCKeditorAPI_GetInstance( instanceName )
{
return this.__Instances[ instanceName ] ;
}

if ( !window.parent.FCKeditorAPI )
{
// Make the FCKeditorAPI object available in the parent window.
FCKeditorAPI = window.parent.FCKeditorAPI = new Object() ;
FCKeditorAPI.__Instances = new Object() ;


// Function used to get a instance of an existing editor present in the
// page.
FCKeditorAPI.GetInstance = FCKeditorAPI_GetInstance ;
}

and then this Code

var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
var letterText.........
oEditor.SetInnerHtml(textver1);

there is error oEditor.SetInnerHtml(textver1); is not a function

Actually Its FCK Editor App ... You may find complete code by searching on google with keywords "FCKEditor"

regards,

Twey
01-10-2007, 11:19 AM
method innerhtml i think overwrites each time when function is calledSimply do:
oDoc.body.innerHTML += ...It still overwrites. This is one of the main problems with innerHTML.
Actually Its FCK Editor App ... You may find complete code by searching on google with keywords "FCKEditor"We'd rather not. This appears to be a question specific to this FCKEditor (which isn't a DD script) and so isn't really appropriate here. I suggest you ask the developers of FCKEditor for support.

easyCodes
01-10-2007, 11:24 AM
We'd rather not. This appears to be a question specific to this FCKEditor (which isn't a DD script) and so isn't really appropriate here. I suggest you ask the developers of FCKEditor for support.
FCKEditor is written in JavaScript... So its pure JS Problem i think this is appropiate place for my Question...... Your Help is Always Appriciated.

regards,

Twey
01-10-2007, 11:27 AM
No, it's no more a pure JS problem than a problem with Windows is a pure C problem.

easyCodes
01-10-2007, 11:49 AM
Ok! Thanks for your help..