Cannot paste <link> or <script> tags into editor, even with enablescriptstrip turned off. Please reply....

Last post 04-10-2006, 3:47 PM by Adam. 12 replies.
Sort Posts: Previous Next
  •  04-03-2006, 2:21 PM 17815

    Cannot paste <link> or <script> tags into editor, even with enablescriptstrip turned off. Please reply....

    Hi, I have created functionality that essentially duplicates the templates dialog box, but for uploading/creating/deleting .css files.
     
    I have everything working except for the one key: after the user checks a checkbox and clicks teh Insert button, the html does not get pasted into the editor that called the dialog box. The javascript code inthe dialog box looks like this:
     
    function InsertIncludeTags()
    {
     //call the instance fo the editor that was passed up, and paste in the value of hidIncludeTags
     //var IncludeTags = document.getElementById("hidIncludeTags").value;
     var IncludeTags = "<link type='text/css' href='UI/CSS/UNG.css' rel=Stylesheet' />";
    var editor=window.dialogArguments;
    try
    {
    //editor.ExecCommand("PasteHTML",false,IncludeTags);
    editor.PasteHTML(IncludeTags);
     }
    catch(e)
    {
     var someting = e.message;
    }
    finally
    {
    window.close();
     }
    }
     
    If I take the < > out of the red text above, then the whole thing works great. Interestingly, I was not even able to paste that line into this instance of the editor while writing this post. I had to type it out, because it kept strippingit.
     
    Is there a setting somewhere for this? Just for the record, I have tried a variety of properties, like enablestripscript=false, disableautoformatiing true/false, etc., but nothign seems to work.
     
    any suggestions would be greatly appreciated, as I've spent quite a bit of time creating this functionality.
     
    Thanks!
     
    Eric
     
    PS: Just to be absolutily clear, the functionality that I have written works perfectly except for it stripping, or rather not allowing the paste of this html.
  •  04-03-2006, 2:37 PM 17818 in reply to 17815

    Re: custom dialog window strips html code before pasting into editor

    By the way, it also works correctly if I put in 'normal' html tags, like <b>, or </table>, and so on, but it always strips <link and <script> tags, even though the enablestripscript is set to false. I am also creating this to work with external .js files, so that they can be included on a page (or even better, in a template).
     
    I have also tried to PasteHTML method directly, as well as teh editor.ExecCommand(PasteHTML), but with identical results.
  •  04-03-2006, 2:52 PM 17819 in reply to 17818

    Re: custom dialog window strips html code before pasting into editor

    Along the same lines, so worth mentioning, while expirimenting with <script> functionality in the editor, I made a very simple page, as follows:
     
    <input id=Button1 onclick=BLOCKED SCRIPTclickthis() type=button value=Button1 name=Button1>
    <script language='javascript'>
    function clickthis()
    {
    alert("help!!!");
    }
    </script>
     
    It doesn't work in Preview mode, and when I view source on the editor Iframe, this is what the rendered code looks like:
     
    <html>
    <head>
    <base href=http://localhost/CuteSoft_Web/ target="blank" /><style> body {padding:0px;margin:0px;}</style>
    </head>
    <body>
    <input id=Button1 onclick=BLOCKED SCRIPTclickthis() type=button value=Button1 name=Button1><body>
    </html>
     
    It looks like the <script> tags got replaced with whatever that is in red.
  •  04-04-2006, 3:17 PM 17866 in reply to 17819

    Re: custom dialog window strips html code before pasting into editor

    Can someone please respond to this...
  •  04-04-2006, 3:53 PM 17869 in reply to 17866

    Re: custom dialog window strips html code before pasting into editor

    Please use the following code instead:

        // get the cute editor instance
        var editor1 = document.getElementById('<%=Editor1.ClientID%>');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument(); 

        var head = editdoc.getElementsByTagName("head")[0];
     
        var style = editdoc.createElement(SomeStyleSheetPath);
        head.appendChild(style);

     

     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-05-2006, 3:06 PM 17913 in reply to 17869

    Re: custom dialog window strips html code before pasting into editor

    Thanks Adam, but no luck; with or withouth the "<Link" part in the string to paste. Also, there doens't seem to be an <html><head></head><body></body></html> section int he html view of the editor (although I have seen it make an appearance before), so I don't know how that code could work if there isn't an available 'head' section.
     
    Also, please remember that I am trying to paste this from a dialog window, so that might factor into your reply.
     
    Your help is much appreciated.  Anyhing else you can think of to try?
     
    Thanks,
     
    Eric
  •  04-05-2006, 3:42 PM 17917 in reply to 17913

    Re: custom dialog window strips html code before pasting into editor

    so, I have it so that I can manually paste the <link> and <script> tags into the html view of the editor, and all is well; the editor does not stript them.
     
    BUT....I still cannot get it to paste from the dialog window (though as I said, i can paste pretty much everything else from that same dialog window).
  •  04-06-2006, 2:20 PM 17950 in reply to 17869

    Re: custom dialog window strips html code before pasting into editor

    This solution didn't work for the reasons I mention in the above posts, but I want to keep this thread going in the hopes that I will get another reply.
     
    Thanks!
     
    Eric
  •  04-06-2006, 8:40 PM 17968 in reply to 17913

    Re: custom dialog window strips html code before pasting into editor

    Eric,
     
    Also, there doens't seem to be an <html><head></head><body></body></html> section int he html view of the editor
     
    Have you set EditCompleteDocument="true" ??
     
    <CE:Editor id="Editor1" EditCompleteDocument="true" runat="server" ></CE:Editor>
     

          
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-06-2006, 8:41 PM 17969 in reply to 17968

    Re: custom dialog window strips html code before pasting into editor

    Eric,
     
    Please use the following code instead:

        // get the cute editor instance
        var editor1 = document.getElementById('<%=Editor1.ClientID%>');
        
        //Get the editor content 
        var editdoc=editor1.GetDocument(); 

        var head = editdoc.getElementsByTagName("head")[0];
        
        alert("Before:"+head.innerHTML);
     
        var style = editdoc.createElement(SomeStyleSheetPath);
        head.appendChild(style);

        alert("After:"+head.innerHTML);
     

     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-07-2006, 12:47 PM 17993 in reply to 17969

    Re: custom dialog window strips html code before pasting into editor

    Thank you, thank you, thank you!! It worked once I added the property editCompleteDocument=true, with your code sample.
     
    I will keep testign it, but thanks, that was driving me nuts!
     
    Eric
  •  04-09-2006, 2:13 PM 18032 in reply to 17969

    Re: custom dialog window strips html code before pasting into editor

    almost there.....
     
    The CSS link insert is working great, but I am still having issues with the <script> part. I have it working so that my dialog box inserts the <script> tags correctly. However, when I look at in in Preview mode, my script does not function. If I view source on the editor, I see that the <script> tags have been stripped, and this has been put in its place:
     
     
    This happens also if I hardcode <script> tags and functions into the html view.
     
    I have enablestripscrips = false.
     
    Any ideas on this one?
     
    Thanks for the help, this is really coming along.
     
    Eric
     
    complete code below:
     
    <html>
      <head>
      </head>
      <body>
          <div><input id=Button1 type=button value=Button1 Name=Button1 OnClick='CallAlert();'></div>
      </body>
    </html>
  •  04-10-2006, 3:47 PM 18072 in reply to 18032

    Re: custom dialog window strips html code before pasting into editor

    Eric,
     
    The JavaScripts in the Editor Preview pane is disabled.
     
    However the JavaScripts are supported in CuteEditor as ong as you set EnableStripScriptTags property to false:
     
    Editor.EnableStripScriptTags Property
     
    Specifies whether to remove inject script before write the string into the db.   
     
    Please test the following page:
     
     
    Hope it helps.
     
    Keep me posted
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML