Hi ztp,
Please try the example below
- <%@ 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">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title>Untitled Page</title>
-
- <script runat="server">
- protected override void OnLoad(EventArgs e)
- {
- editor1.Text = "<a href='http://www.cnn.com'>far west</a>";
- base.OnLoad(e);
- }
- </script>
-
- </head>
- <body>
- <form id="form1" runat="server">
- <CE:Editor ID="editor1" runat="server">
- </CE:Editor>
- <input type="button" value="ChangeLink" onclick="changeLink()" />
- </form>
- </body>
- </html>
-
- <script>
- function changeLink()
- {
- var editor1 = document.getElementById("<%= editor1.ClientID %>");
- var tempUrl = 'http://tempuri.org/tempuri.html';
- editor1.ExecCommand('insertlink',null,tempUrl);
- var links = editor1.GetDocument().getElementsByTagName('a');
- for (var i=0;i<links.length;i++)
- {
- if (links[i].href == tempUrl)
- {
- link = links[i];
- break;
- }
- }
- link.setAttribute("href_cetemp","http://www.cnn.com/")
- link.target = "abc";
- }
-
- </script>
Regards,
ken