Hi AviPic,
Please try the example below. Insert a image, add alt property ,select it and click the button.
- <%@ Page Language="C#" AutoEventWireup="true" %>
-
- <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <CE:Editor ID="editor1" runat="server">
- </CE:Editor>
- <input type="button" value="getALT" onclick="getALT()" />
- </form>
- </body>
- </html>
-
- <script>
- function getALT()
- {
- alert(getSelectedHTML());
- }
- function getSelectedHTML(){
- var editor1=document.getElementById("<%= editor1.ClientID %>");
-
- var editwin = editor1.GetWindow();
-
-
-
- var editdoc = editor1.GetDocument();
-
- var rng=null,html="";
- if (document.selection && document.selection.createRange){
-
- rng=editdoc.selection.createRange();
- html=rng.htmlText||"";
- }
- else if (window.getSelection){
-
- rng=editwin.getSelection();
-
- if (rng.rangeCount > 0 && window.XMLSerializer)
- {
- rng=rng.getRangeAt(0);
- for(var i=0;i<rng.startContainer.childNodes.length;i++)
- {
- if(rng.startContainer.childNodes[i].tagName=="IMG")
- {
-
- html=rng.startContainer.childNodes[i].alt;
- }
-
- }
-
- }
- }
-
- return html;
- }
- </script>
Regards,
Ken