<body> value can be change

Last post 04-12-2009, 9:48 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  04-09-2009, 4:33 AM 50916

    <body> value can be change

    hi all
     
    i would like to ask whether i can call a javascript to change the <body> value of the editor ?
     
    for example, from <body> change to <body style="background-repeat: no-repeat" background=http://localhost:2341/eTemplate_develop/member/template/xyz.jpg" border="1"> when the javascript function is call (button click)
     
    i try to change the background image when a button is click, but until now i still fail to find any solutions..
     
    hopefully someone can help me this
     
    thanks
  •  04-09-2009, 10:25 AM 50931 in reply to 50916

    Re: <body> value can be change

    Hi goh6613,
     
    Try this way:
     
    Need to go to HTML view
     

    <%@ Page Language="C#" %>

    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <script>
    function changeBodyStyle()
    {
        var editor1 = document.getElementById('<%= Editor1.ClientID%>');
        var content = editor1.GetHTML();
        var cleanContent=content.replace(/(<body[^\>]*\>)/i, "<body style='background-repeat: no-repeat' background='http://localhost:2341/eTemplate_develop/member/template/xyz.jpg' border='1'> ");
        editor1.SetHTML(cleanContent)
    }

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CE:Editor ID="Editor1" runat="server" EditCompleteDocument="true">
                </CE:Editor>
                <input id="Button1" type="button" value="button" onclick="changeBodyStyle()" />
            </div>
        </form>
    </body>
    </html>

     
     
    Regards,
     
    Ken
  •  04-09-2009, 8:20 PM 50955 in reply to 50931

    Re: <body> value can be change

    hi Kenneth
     
    thanks for ur replies.
     
    i tried it, but the replace method seem like just work inside its content,when i try to replace <body> values, it did not work, may i know what happen, or i can clear it content and regenerate it ?
     
    thanks 
  •  04-12-2009, 9:48 PM 51012 in reply to 50955

    Re: <body> value can be change

    Hi goh6613,
     
    We working on this example, and will get back to you as soon as possible.
     
    And the example I provide before, you need to switch to the html view then click the button to get it works.
     
    Regards,
     
    Ken
View as RSS news feed in XML