Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem initializing designMode on DOM-generated element

    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
    Code:
    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?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.



    Do I just need to toss an innocuous try...catch around it to avoid the error?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 );
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •