htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
"offsetWidth is null or not an object"


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


mmcw
User

Aug 6, 2004, 5:57 AM

Post #1 of 4 (7585 views)
Shortcut
"offsetWidth is null or not an object" Can't Post

I sometimes get the error: "offsetWidth is null or not an object"

I did search the forum for that error and fould a lott of people who had the same problems! I did try a few solution they told sould fix the problem! Noen of them did.

I think the problem is caused by the following!


Code
   

// Creates the HTMLArea object and replaces the textarea with it.
HTMLArea.prototype.generate = function () {
var editor = this; // we'll need "this" in some nested functions
// get the textarea
var textarea = this._textArea;
if (typeof textarea == "string") {
// it's not element but ID
this._textArea = textarea = HTMLArea.getElementById("textarea", textarea);
}



I did some research myself and fould out that at the moment the error was show the value:

var textarea = this._textArea; // wil not be set and will return null.

When textarea will be null there will be a problem!! Sometimes however it will work and the error will not be shown! STRANGE!

I am using IE 6.01 on a WIN XP machine

Maybe someone can help me or can do something with my research!


mmcw
User

Aug 6, 2004, 9:30 AM

Post #2 of 4 (7570 views)
Shortcut
Re: [mmcw] "offsetWidth is null or not an object" [In reply to] Can't Post

It looks like the part:


Code
  if (typeof textarea == "string") { 
// it's not element but ID
this._textArea = textarea = HTMLArea.getElementById("textarea", textarea);
}



is returning sometimes null.

When a delay is entered like:

alert(textarea);

the error does not show up.

Starnge - Looks like a timing problem! Does anyone know how to fix or how to add a small delay?


JCollum
Novice

Nov 17, 2004, 9:22 AM

Post #3 of 4 (7240 views)
Shortcut
Re: [mmcw] "offsetWidth is null or not an object" [In reply to] Can't Post

Does anyone have a solution to this one? I made some minor changes to my page (not related to HTMLArea) and all of a sudden this happens. I agree, it is because this._textArea is evaluating to null. It's getting lost somehow because it was valid a few lines ago.

Update: OOPS. I was initializing the editor in my page_load event (ASP.NET) and somehow that event got unhooked from my page. So the editor was never actually there. So the getElementByID method doesn't work, which breaks the whole thing.


(This post was edited by JCollum on Nov 17, 2004, 9:44 AM)


AG
Novice

Feb 11, 2005, 8:26 AM

Post #4 of 4 (6757 views)
Shortcut
Re: [mmcw] "offsetWidth is null or not an object" [In reply to] Can't Post

i had this problem and my fix was to make sure that you specify the ID for the textarea (not just the name)

 
 
 


Search for (options)