Style tag in Head tag problem (removed by editor)

Last post 08-04-2008, 6:01 AM by MarkMyWords. 7 replies.
Sort Posts: Previous Next
  •  07-23-2008, 4:31 AM 42461

    Style tag in Head tag problem (removed by editor)

    Hi,
     
    I am experiencing an issue using STYLE tags whilst using the editor in FullPage="True" mode -- i.e so that it allows you to include and edit the HTML, HEAD and BODY tags.  This works well until I try to put a STYLE tag in the HEAD tag.  Like so...
     
    (html)
      (head)
         (style type="text/css")
             body {color: red}
         (/style)
      (/head)
      (body)
         This is a test
      (/body)
    (/html)
     
    The editor renders this correctly by when I post-back and then get the Editor1.Text on the server side: the STYLE tag has been stripped completely and the body {color:red} appears inside the BODY tag as actual page content.  So it ends up looking something like...
     
    (html)
      (head)
      (/head)
      (body)
         body {color: red}    
        This is a test
      (/body)
    (/html)
     
     
    I can re-create the problem by editing the full HTML page using this example...
     
     
    ... try putting a STYLE tag in the HEAD and saving.
     
    Please help!
     

    <CE:Editor id="Editor1" FullPage="True" EditorWysiwygModeCss="css/cuteedit.css" runat="server"></CE:Editor>

    Filed under:
  •  07-23-2008, 5:37 AM 42464 in reply to 42461

    Re: Style tag in Head tag problem (removed by editor)

     
    You can get a similar problem to occur if you run the following javascript, where the STYLE tag is moved/removed/corrupted...
     
     

    document.getElementById('CE_Editor1_ID').setHTML("<html><head><style>body {color: red;}</style></head><body>This should be red</body></html>");

     
    Please note that you cannot test or demo this problem in the example link (http://cutesoft.net/example/general.aspx) because it does not have the FullPage="True" set.  But you can re-create the problem using http://cutesoft.net/example/Edithtml.aspx 
  •  07-24-2008, 4:23 AM 42496 in reply to 42461

    Re: Style tag in Head tag problem (removed by editor)

    Is ther eany news on this?  Is this a bug or is there a setting I can change to stop this happening?
     
    Please let me know.  Thanks. Mark
  •  07-24-2008, 8:32 AM 42499 in reply to 42496

    Re: Style tag in Head tag problem (removed by editor)

    That sounds just like the problem i had!
     
    Assuming it is the same problem, cutesoft have added some new properties to the editor which changes the default behaviour! It caught me out and now it seems to have caught out cutesoft themselves as shown in the demo link! http://cutesoft.net/example/Edithtml.aspx
     
    Which is why if you add new properties you should default them to whatever the previous version did.... (sorry just a little ranting there!) I found it very annoying especially as we did not know what new features had been added.
     
    Anyway the new property you need to set to false is.......
    EnableStripStyleTagsCodeInjection
     
    Look out for
    EnableStripLinkTagsCodeInjection
    EnableStripIframeTags
     
    These also caught me out too! All these are now detailed on http://cutesoft.net/forums/42363/ShowThread.aspx#42363
     
    Hope this helps!
     
     
  •  07-25-2008, 3:51 AM 42538 in reply to 42499

    Re: Style tag in Head tag problem (removed by editor)

    Hi Andy,
     
    Thanks for the heads-up on that.  Ive been playing with that setting and it appears to work well -- although now I cannot recreate the problem.  Must be a friday thing.
     
    Ill try to find out what's actually happening and will post any update here.
     
    Mark
     
  •  07-25-2008, 5:28 AM 42540 in reply to 42538

    Re: Style tag in Head tag problem (removed by editor)

     
    Ok, probably the final word on this, unless CuteSoft support can solve my final issue below.  
     
    As Andy pointed out, the STYLE in the HEAD tag is not stripped out if you set the following property on the editor...

         Editor1.EnableStripStyleTagsCodeInjection = false;

    This is great and appears to work well, however, if you try to "save" the HTML by using the built-in Save button then the Editor1.Text that you get the other end still strips the STYLE tag from the HEAD tag and sticks the contents in the BODY tag.  So, I fixed this by...
     
    1) Removing the standard Save button
    2) Adding my own custom Save button that calls a SaveHtml() javascript function, which works a bit like this...
     

    function SaveHtml() {
      // Get live HTML from editor
      var html = document.getElementById('CE_Editor1_ID').getHTML();
      // Push into hidden form-post field
      document.getElementById('htmldata').value = html;
      // Post form
      document.form1.submit();
    }

  •  07-25-2008, 2:43 PM 42551 in reply to 42540

    Re: Style tag in Head tag problem (removed by editor)

    >>Ifyou try to "save" the HTML by using the built-in Save button then the Editor1.Text that you get the other end still strips the STYLE tag from the HEAD tag and sticks the contents in the BODY tag.
     
    Can you try the save button in the following example:
     

    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

  •  08-04-2008, 6:01 AM 42718 in reply to 42551

    Re: Style tag in Head tag problem (removed by editor)

    Adam:
    >>Ifyou try to "save" the HTML by using the built-in Save button then the Editor1.Text that you get the other end still strips the STYLE tag from the HEAD tag and sticks the contents in the BODY tag.
     
    Can you try the save button in the following example:
     
     
     
    Hi Adam,
     
    Thank you for the message.  I have tried on that page and it works.  Wired thing is that it doesnt work for me with the same flag set .  Must be something I'm doing.   Ill get the latest source cut and bash it through again.
     
    Thanks
     
    Mark
View as RSS news feed in XML