...

Problem initializing designMode on DOM-generated element

beetle
07-14-2003, 06:43 PM
I'm having problems getting an IFRAME into designMode in Gecko. It works fine if the element is hard-coded into the HTML, but if I create it via DOM scripting, I get the following error

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.designMode]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/work/peterbailey.net/test/rte/new/js/GildedRTE.js :: enableDesignMode :: line 33" data: no]
I've tried both document.createElement and document.createElementNS to creame the IFRAME, both cause the error. Here's how I'm attempting to turn designMode on
function enableDesignMode( id )
{
var iframe = document.getElementById( id );
if ( iframe.contentDocument )
{
iframe.contentDocument.designMode = "on"; // This is line 33 that the error mentions
}
else
{
iframe.document.designMode = "On";
}
}
Like I said, this function works on hard-coded IFRAME elements.

Any clues?

beetle
07-14-2003, 06:53 PM
UPDATE

I was forgetting setAttributeNS too. Now that I've done that, it turns designMode on (I can type in the IFRAME) but it still throws the exact same error.

:confused:

Do I just need to toss an innocuous try...catch around it to avoid the error?

beetle
07-14-2003, 07:01 PM
UPDATE to the UPDATE

Using the try...catch works, but something is still amiss. When comparing the effects of the enableDesignMode function on my DOM-generated IFRAMEto a hard-coded IFRAME, there are some discrepancies.

For example: none of the navigation keys work (Home, End, PgUp, PgDown, all four arrows) in the DOM-generated IFRAME. Neither do Insert or Delete.

:confused: :confused:

jkd
07-14-2003, 07:21 PM
http://bugzilla.mozilla.org/show_bug.cgi?id=191994

Seems related.

beetle
08-05-2003, 11:22 PM
I got it fixed. I needed to add a timeout to give the operation some "breathing room" or something.

setTimeout( function() { iframe.contentDocument.designMode = "on"; }, 10 );



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum