Re: add a marquee tag properties on text

  •  06-19-2012, 11:32 AM

    Re: add a marquee tag properties on text

    Hi pilotsredlix,
     
    The style builder of editor has not the function to add a <marquee> target for the selected text.
     
    If you want to wrap the selected text as the <marquee> target, then please try the example below. 
     
    1. <%@ Page Language="C#" AutoEventWireup="True" %>  
    2.   
    3. <%@ Register TagPrefix="CE" Assembly="CuteEditor" Namespace="CuteEditor" %>  
    4. <html>  
    5. <head>  
    6. </head>  
    7. <body>  
    8.     <form id="Form1" runat="server">  
    9.         <CE:Editor ID="editor1" runat="server">  
    10.         </CE:Editor>  
    11.         <input type="button" value="add marquee target" onclick="addMarquee()" />  
    12.     </form>  
    13. </body>  
    14. </html>  
    15.   
    16. <script>  
    17. function addMarquee()  
    18. {  
    19.     var editor1=document.getElementById("<%= editor1.ClientID %>");  
    20.     var code=getSelectedHTML();  
    21.     editor1.PasteHTML("<marquee>"+code+"</marquee>");  
    22. }  
    23. function getSelectedHTML()        
    24. {           
    25.     var editor1=document.getElementById("<%= editor1.ClientID %>");  
    26.       var rng=null,html="";              
    27.            
    28.       // get the active editor document     
    29.       var editdoc = editor1.GetDocument();     
    30.     
    31.       // get the active editor window      
    32.       var editwin = editor1.GetWindow();        
    33.       if (document.selection && document.selection.createRange)        
    34.       {           
    35.             rng=editdoc.selection.createRange();        
    36.            if( rng.htmlText )         
    37.            {         
    38.               html=rng.htmlText;         
    39.            }         
    40.            else if(rng.length >= 1)         
    41.            {         
    42.               html=rng.item(0).outerHTML;         
    43.            }        
    44.       }        
    45.       else if (window.getSelection)        
    46.       {        
    47.             rng=editwin.getSelection();        
    48.             if (rng.rangeCount > 0 && window.XMLSerializer)        
    49.             {        
    50.                   rng=rng.getRangeAt(0);        
    51.                   html=new XMLSerializer().serializeToString(rng.cloneContents());        
    52.             }        
    53.       }        
    54.       return html;        
    55. }     
    56. </script>  
    Regards,
     
    Ken 
View Complete Thread