0
나는 CKEDITOR의 텍스트 영역에서 선택한 항목을 경고하려고합니다. 내가 달릴 때는 "No text is selected."
이 나온다. 나는 경보를보고 싶다 내가 여기서 바꿀 필요가 있다고 생각한다. var textarea = document.getElementById('editor1');
아무도 나를 도와 줄 수 있을까 ??CKEDITOR의 텍스트 영역에서 선택 항목에 경고하는 중
설정 :
function()
{
var selection = "";
var textarea = document.getElementById('editor1');
if ('selectionStart' in textarea)
{
// check whether some text is selected in the textarea
if (textarea.selectionStart != textarea.selectionEnd)
{
selection = textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
}
}
else
{
// Internet Explorer before version 9
// create a range from the current selection
var textRange = document.selection.createRange();
// check whether the selection is within the textarea
var rangeParent = textRange.parentElement();
if (rangeParent === textarea)
{
selection = textRange.text;
}
}
if (selection == "")
{
alert("No text is selected.");
}
else
{
alert("The current selection is: " + selection);
}
}
선택한 텍스트가 단락의 일부인 경우 < p > 태그로 구분되지 않으며 HTML 태그 메서드는 아무 것도 반환하지 않습니다. 모든 경우를 포괄하는 두 가지 솔루션을 결합하십시오! –