Insert javascript file inside editor's document

8 posts, 0 answers
  1. Subodh
    Subodh avatar
    11 posts
    Member since:
    Aug 2007

    Posted 27 Apr 2009 Link to this post

     

    I can insert my custom css inside editor's document/head object like

    <telerik:radeditor runat="server" ID="RadEditor1" >

    <CssFiles>

       <telerik:EditorCssFile Value="mycss.css" />

    </CssFiles>

    </telerik:radeditor>

     

     

     

    Similarly I want to insert my custom javascript inside editor's document. How can I do this?

    I have developed some custom tools, like my own image and when user mouseovers the image in editor I want to display some alignment buttons or information icons on it. So I have written the code on mouseover-out etc events in my custom js file.

  2. Subodh
    Subodh avatar
    11 posts
    Member since:
    Aug 2007

    Posted 28 Apr 2009 Link to this post

    well the solution I found is add following script bellow the editor

            var editor = null;  
            function AddJavascriptFile(sfileUrl, oDocument) {  
                var theDoc = oDocument != null ? oDocument : document;  
                var oScript = theDoc.createElement("script");  
                oScript.setAttribute("src", sfileUrl, 0);  
                oScript.setAttribute("type""text/javascript");  
                var oHead = theDoc.getElementsByTagName("head")[0];   
                oHead.appendChild(oScript);  
            }  
     
            Sys.Application.add_load(function() {  
                var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor's client object  
                var oDocument = editor.get_document(); //  
                AddJavascriptFile("myownjavascript.js", oDocument);  
             }  
          ); 

    This works perfectly.
    But I am still looking for authentic way of doing the same
  3. Rumen
    Admin
    Rumen avatar
    13804 posts

    Posted 28 Apr 2009 Link to this post

    Hello Subodh,

    By default RadEditor removes all script tags to prevent the execution of malicious content in it. You can easily disable the content filter responsible for the <script> tags stripping by setting the line below via the codebehind:

    RadEditor1.DisableFilter(EditorFilters.RemoveScripts);

    Best regards,
    Rumen
    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.
  4. Subodh
    Subodh avatar
    11 posts
    Member since:
    Aug 2007

    Posted 28 Apr 2009 Link to this post

    Thanks for the reply; but the question remains same how to add the script file?

    I want to add javascript file reference in head tag of rad editor's iframe's document.
  5. Rumen
    Admin
    Rumen avatar
    13804 posts

    Posted 01 May 2009 Link to this post

    Hi Subodh,

    The simplest way is to use Full HTML Page Editing of RadEditor as it is demonstrated in this live example: Full HTML Page Edit.

    Best regards,
    Rumen
    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.
  6. Cary Abramoff
    Cary Abramoff avatar
    20 posts
    Member since:
    Aug 2009

    Posted 10 Jun 2011 Link to this post

    I have same issue.
    After reading this post I was quite disappointed.
    Rumen's answer is a NON-ANSWER, as if to tell Subodh to go away.
    I tried Subodh's solution but it did not work for me.
    So two people who gave parital, out of context posts end up personifying the old adage, "haste makes waste"
  7. Rumen
    Admin
    Rumen avatar
    13804 posts

    Posted 15 Jun 2011 Link to this post

    Hi Cary,

    Subodh's solution works as expected. You can see how it works in the following video: http://screencast.com/t/YI6rPgc6X. For your convenience I have attached my test page.

    Another approach is to register the scripts in the head of the page with RadEditor and set the ContentAreaMode property to DIV. This will render the content area of RadEditor as an editable DIV element which is part of the current page and the scripts will be accessible in the RadEditor's body as well.

    I also logged your request in our PITS system and if more users vote for it we will consider implementing it for a future version of the control. Here you can find the PITS Issue: Public URL.

    Best regards,
    Rumen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  8. Cary Abramoff
    Cary Abramoff avatar
    20 posts
    Member since:
    Aug 2009

    Posted 15 Jun 2011 Link to this post

    Hi,

    I received your email pointing to this post. That is very much appreciated. I got Subodh's solution working right away but in my case I was trying to get colorbox.js plugin working.

    The radeditor, sometimes, in some browsers, displayed my images as lightbox shows and othertimes, in other browsers, did not. I use many radeditors in my site, and I needed a rock solid solution.

    ... so unfortunately I could not rely upon the radeditor and lightbox/colorbox plugin due to composability issues. 

    The radeditor is a great product as it is what brought me to Telerik in the first place 2 years ago and for asp.net development I could never imagine using another product. I was an obout suite refugee and the Telerik experience blew them away and saved my business model.

    That being said I am now trying to move away from asp.net all together in favor of pure amazon s3 jquery UI development. asp.net scaling is a nightmare in the cloud!

    My final solution to the scripts issue was to use iframes.

    Love those iframes!

    Cary
Back to Top