Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Cute Editor for .NET
»
Re: how can my page recognise which "div" is selected
Re: how can my page recognise which "div" is selected
09-06-2009, 2:57 AM
Kenneth
Joined on 02-13-2008
Posts 3,886
Re: how can my page recognise which "div" is selected
Reply
Quote
HI goh6613,
Try this way
<%@ 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>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head id=
"Head1"
runat=
"server"
>
<title>Untitled Page</title>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<CE:Editor ID=
"Editor1"
runat=
"server"
>
</CE:Editor>
</form>
</body>
</html>
<script>
var editor1=document.getElementById(
'<%= Editor1.ClientID %>'
);
function getSelectedHTML(){
// get the active editor window
var editwin = editor1.GetWindow();
// get the active editor document
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);
html=
new
XMLSerializer().serializeToString(rng.cloneContents());
}
}
return
html;
}
function CuteEditor_OnCommand(editor,command,ui,value)
{
var editdoc = editor1.GetDocument();
if
(command==
"InsertLayer"
)
{
if
(editdoc.selection.type==
"Control"
)
{
return
true
;
}
}
}
</script>
Regards,
ken
View Complete Thread