document.domain Access Denied in IE 6

12 posts, 0 answers
  1. bemana
    bemana avatar
    14 posts
    Member since:
    Dec 2006

    Posted 28 Jan 2009 Link to this post

    I'm using document.domain in my application so that I can access properties (DOM) of another website using javascript.  Using document.domain has broken the RadEditors that I'm using.  I'm getting Access Denied errors in IE 6.  It works in Firefox.  I can guess why this is happening.  The RadEditor is using an iframe and the source document's document.domain is not set to the same value.  My understanding that IE 6 requires you to explicity set this value in all windows.

    var

     

    doc=this._textIframe.contentWindow.document;

     


    That's where one of the errors occurs in the telerik javascript.  Basically the iframe isn't accessable from the parent window and the editor just doesn't work at all.  

    I think this probably a bug in IE 6 as it should inherit the document.domain setting from the parent window, but it doesn't apparently.  You have to explicity set it.  The src of the iframe is:

    javascript:'<html></html>


    which isn't a phyiscal page where someone could add:
    document.domain = "whatever";

    I'm using the latest ajax RadEditor.  Any idea how I can solve this?  Thanks,

    Randy

  2. bemana
    bemana avatar
    14 posts
    Member since:
    Dec 2006

    Posted 28 Jan 2009 Link to this post

    After submitting this post I did a little more seaching around and found an article that explains the problem in more detail:

    http://waelchatila.com/2007/10/31/1193851500000.html

    Still no solution apparently.

  3. Jeff Tucker
    Jeff Tucker avatar
    2 posts
    Member since:
    Aug 2007

    Posted 20 Aug 2009 Link to this post

    We are running into this issue as well.  Has there been any resolution?

  4. Lini
    Admin
    Lini avatar
    2143 posts
    Member since:
    Sep 2012

    Posted 21 Aug 2009 Link to this post

    Hi ,

    Unfortunately, we have not been able to find a workaround for this problem. Setting the document.domain property in the editor IFRAME is not possible, because we cannot access it in the first place (see http://msdn.microsoft.com/en-us/library/ms533028%28VS.85%29.aspx). This is a security issue with IE, and Microsoft is reluctant to change the browser behavior.

    All the best,
    Lini
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  5. Jeff Tucker
    Jeff Tucker avatar
    2 posts
    Member since:
    Aug 2007

    Posted 21 Aug 2009 Link to this post

    I believe the problem is in the way you intialize the iFrames.  As a proof of concept I have done the following:

    function ChangeSrc(sender) {  
        var edtr = sender;  
        var source = "javascript:void((function(){document.open();document.domain=\'tld.com\';document.close();})())";  
        if (typeof edtr._contentAreaElement == "undefined" || edtr._contentAreaElement == null) {  
            var elem = document.createElement("iframe");  
            elem.frameBorder = "0";  
            elem.src = source;  
            elem.style.width = "100%";  
            elem.style.margin = "0px";  
            elem.style.padding = "0px";  
            elem.setAttribute("id", edtr.get_id() + "_contentIframe");  
            edtr._contentAreaElement = elem;  
        } else {  
            //Permission denied  
            try { alert(edtr._contentAreaElement.contentWindow.document.domain); } catch (e) { }  
            edtr._contentAreaElement.src = source;  
            //Permission granted  
            try { alert(edtr._contentAreaElement.contentWindow.document.domain); } catch (e) { }  
        }  
    }  
     
    function RadEditor_OnClientInit(sender) {  
        ChangeSrc(sender);  
    }  
     
    function RadEditor_OnClientLoad(sender) {  
        ChangeSrc(sender);  

    There are probably several ways of initializing the iframe with the document.domain specified.  The technique above I found in the FCKEditor source code, so I am not sure what the ramifications of that are. 

    Now even though the code above does work to set the document.domain and does give the parent window access, the editor still doesn't work in IE.  I assume this is because of other dependencies of which I am unaware.

    Suggestions?

  6. Lini
    Admin
    Lini avatar
    2143 posts
    Member since:
    Sep 2012

    Posted 25 Aug 2009 Link to this post

    Hi,

    Thank you for sharing this code. We will try to integrate it again in the editor and see if the document.domain scenario can be fixed. I think that the changes will be more than just setting the src of the content iframe. The editor uses several iframes and the code needs to be added for all of them. Also, we sometimes rewrite the content of some frames (e.g. when the editor content is set) so we need to handle that as well. Finally, the contentWindow.document object of the iframe is not available immediately after adding the iframe to the DOM. We will do our best to fix this scenario before the next official RadControls release.

    Sincerely yours,
    Lini
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  7. Ryan
    Ryan avatar
    5 posts
    Member since:
    Feb 2009

    Posted 18 May 2010 Link to this post

    Has a fix been implemented for this yet? We are running an application with document.domains explicitly set in order to facilitate cross server scripting on the same domain. The RadEditor is throwing "access denied" errors when building the iframes.

  8. Rumen
    Admin
    Rumen avatar
    12570 posts
    Member since:
    Sep 2012

    Posted 21 May 2010 Link to this post

    Hi Ryan,

    The problem is still not fixed because the content area of RadEditor is an editor IFRAME element.

    We are currently working on a new content area mode based on an editable DIV which will allow us to fix the problem. The new DIV editable mode is planned for Q2 2010 release of the control, which is scheduled for the beginning of July.

    Greetings,
    Rumen
    the Telerik team


    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  9. Rodolfo
    Rodolfo avatar
    2 posts
    Member since:
    Sep 2010

    Posted 25 Sep 2010 Link to this post

    Was this released in July? I believe I'm hitting this issue now, using v5.8.1

  10. Rumen
    Admin
    Rumen avatar
    12570 posts
    Member since:
    Sep 2012

    Posted 27 Sep 2010 Link to this post

    Hello Rodolfo,

    RadEditor for MOSS v5.8.1 offers the ability to render its content area as an editable DIV element. All you need to do is to set the ContentAreaMode property as shown below:

    <property name="ContentAreaMode">Div</property>

    in the ConfigFile.xml / ListConfigFile.xml file.

    Kind regards,
    Rumen
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

  11. Rodolfo
    Rodolfo avatar
    2 posts
    Member since:
    Sep 2010

    Posted 27 Sep 2010 Link to this post

    Thanks Rumen,

    Very quick response, that seemed to be the answer, but unfortunately my developer reported back:

    ...when we try this we can't invoke the Link Manager because we get:

     

    Webpage error details

     

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3; Zune 4.0)

    Timestamp: Mon, 27 Sep 2010 12:31:28 UTC

     

     

    Message: Object required

    Line: 86

    Char: 2

    Code: 0

    Do you have any idea why this would be?

    Thanks for your response.

  12. Rumen
    Admin
    Rumen avatar
    12570 posts
    Member since:
    Sep 2012

    Posted 30 Sep 2010 Link to this post

    Hello Rodolfo,

    The problem is due to that the LinkManager dialog use an IFRAME element for its content area.

    My suggestion is to test the MOSSLinkManager and InsertLink and if they work as expected in document.domain scenario to use them instead of the iframe based LinkManager dialog.

    The Insert Link dialog is a light version of Hyperlink Manager. When enabled, its content is rendered on page load and as a result the content is immediately loaded when the diaolg is shown without any delay. In order to have it decorated you should put a RadFormDecorator on the main page.

    You can see how to add / remove the toolbar buttons in this article: Add/Remove tools from the toolbar.

    Sincerely yours,
    Rumen
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Back to Top