powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Положение курсора в форме ?
9 сообщений из 9, страница 1 из 1
Положение курсора в форме ?
    #35198166
Фотография pahhan
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Всем привет!
Есть такая задача: есть форма для ввода текста, над формой - ссылочки, например , - и т.д., как на форумах.
Задача: пользователь нажимает на одну из ссылочек, и в форме появляется соответствующее значение. Например, если нажать по ссылке , в форму выводится bold и т.д.
Это я написал, но я не знаю как определить положение курсора в форме. То есть мне надо, чтобы соответствующее значение выводилось в конце всего текста, который уже есть в форме. Как это сделать?
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198189
Фотография SkyLight
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Если надо, чтоб выводилось в конце всего текста, то зачем определять положение курсора? Просто дописал к value поля то что надо и всё
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198196
Фотография krvsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Как вариант ...
----------
Cache for Windows (Intel) 2007.1 (Build 369) Fri Jun 15 2007 15:25:42 EDT
Cache for Windows NT (Intel) 5.0.20 (Build 6305) Fri Sep 16 2005 11:54:10 EDT
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198287
IDVsbruck
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Не очень понятен вопрос. Определение курсора в форме - это знать, какой элемент в данный момент редактируется или положение курсора в, к примеру, textArea?
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198305
Фотография pahhan
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Большое спасибо!
IDVsbruck, в TextArea.
А если куча текста, оно не будет медленно срабатывать если дописывать к value?
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198387
Фотография krvsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
pahhanА если куча текста
Насколько большая куча? Там вроде textarea имеет ограничения по данным...
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35198901
Фотография pahhan
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Ну я не знаю насколько она может быть большая ))
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35199511
Фотография krvsa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Даже ES-ки довольно шустро могли работать с текстами соизмеримыми с textarea.
----------
Cache for Windows (Intel) 2007.1 (Build 369) Fri Jun 15 2007 15:25:42 EDT
Cache for Windows NT (Intel) 5.0.20 (Build 6305) Fri Sep 16 2005 11:54:10 EDT
...
Рейтинг: 0 / 0
Положение курсора в форме ?
    #35200072
Гость2323
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Вот пример из MSDN целиком страница

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML xmlns:MSHelp=http://msdn.microsoft.com/msHelp>
<HEAD>
<TITLE>Editable Regions Sample</TITLE>

<STYLE>
BODY{margin: 0 ;
        background:white;
        font-family:verdana;
        font-size: 80 %;}
BUTTON {cursor:hand;
        background:#ffffff; 
        border-color:#99ccff; 
        font-weight:bold;}
.bar{background:# 336699 ;
        width: 100 %;
        height:30px;
        border-top:1px solid #99CCFF;
        border-bottom:1px solid # 000000 ;}
.desbar{background:#FFFFFF;
        width: 100 %;
        padding: 10px;
        border-top:1px solid #CCCCCC;
        border-bottom:1px solid # 000000 ;
        color:black; 
        font-size:8pt;
        height: 105 ;}
.title{font-size:15pt;
        color:white;
        padding-left:10px;}
.bar A:link {text-decoration:none; color:white}
.bar A:visited {text-decoration:none; color:white}
.bar A:active {text-decoration:none; color:white}
.bar A:hover {text-decoration:none; color:yellow}
</STYLE>

<SCRIPT>
<!-- The fnInit function initializes the editable and non-editable regions -->
<!-- of the document                                                       -->     
function fnInit(){
    <!-- Ensure the display interface is not selectable, by making all     -->
    <!-- elements UNSELECTABLE                                             -->
    for (i= 0 ; i<document.all.length; i++)
            document.all(i).unselectable = "on";
    <!-- Prepare the editable regions                                      -->
    oDiv.unselectable = "off";
    oTextarea.unselectable = "off";
}

<!-- The fnToggleEdits function turns editing on or off in the editable -->
<!-- regions of the document                                            -->     
function fnToggleEdits(oObj,oBtn) {
    currentState = oObj.isContentEditable;
    newState = !currentState;
    oObj.contentEditable = newState;
    
    newState==false ? oBtn.innerHTML='Turn Editing On' :
        oBtn.innerHTML='Turn Editing Off';
}

</SCRIPT>
<LINK REL="stylesheet" TYPE="text/css" HREF="ms-help://Hx/HxRuntime/HxLink.css"><STYLE TYPE="text/css">
	PRE.clsCode { font-size: 110 %; } 
	PRE.clsSyntax { font-size: 100 %; }  
	TD DIV.clsBeta { display:none;}
  MSHelp\:link {
    color:#0000ff;
    text-decoration:underline;
    cursor:hand;
    hoverColor:#3366ff;
    filterString: ;}
</STYLE>
</HEAD>

<BODY onload="fnInit();">

<DIV CLASS="bar title">Editable Regions Sample</DIV>
 
<DIV CLASS="desbar">
    <H4 style="font-size:10pt;">This example demonstrates the features of 
        Microsoft® Internet Explorer that enable users to edit the content
        of an HTML element directly from the browser.</H4>
    <P>This HTML editor is a <B>DIV</B> element set to be content-editable. Any 
        valid HTML content (text, images, form controls, etc.) can be pasted 
        and edited in this editor.</P>

    <DIV ALIGN="center">
        <DIV ALIGN="center" STYLE="height:210; width:90%; 
            background-color:#99CCFF; border:1px solid black">  
            <DIV CLASS="bar title">HTMLEditor (Content-Editable DIV)</DIV>

            <DIV style="padding:10px">
                <BUTTON ID="oEditDiv" TITLE="Turn Editing Off"
                  onclick='fnToggleEdits(oDiv,oEditDiv);oDiv.focus();'>
                  Turn Editing Off</BUTTON>  
                <BUTTON ID="oBoldBtn" TITLE="Bold" 
                  onclick='if (oDiv.isContentEditable==true) 
                  document.execCommand("Bold");'><B>Bold</B></BUTTON>  
                <BUTTON ID="oItalicBtn" TITLE="Italic" 
                  onclick='if (oDiv.isContentEditable==true) 
                  document.execCommand("Italic");'><I>Italic</I></BUTTON>  
                <BUTTON ID="oUndLnBtn" TITLE="Underline" 
                  onclick='if (oDiv.isContentEditable==true) 
                  document.execCommand("Underline");'><U>Underline</U></BUTTON>
            </DIV>
            <DIV id=oDiv CONTENTEDITABLE ALIGN=left STYLE="height:100; 
                width:95%;background-color:white; font-face:Arial; padding:3;    
                border:inset #99ccff; scrollbar-base-color:#99ccff; 
                overflow=auto;"></DIV> 
            <BUTTON TITLE="Append from HTMLEditor" 
                onclick='oTextarea.value+=oDiv.innerHTML;oTextarea.focus();'>
	            Append to TextEditor</BUTTON>
        </DIV>
    </DIV>

    <P>This text editor is a <B>TEXTAREA</B> element and is content-editable by 
        default. Only text can be edited in this tool. However, you can draft 
        HTML in the TEXTEditor and press the <B>Append to HTMLEditor</B> button 
        to see the result appended to HTMLEditor. The <B>Append to  
        TextEditor</B> button reverses this process by appending the 
        HTMLEditor's HTML as text to the TEXTEditor.
    </P>
    <BR/>

    <DIV ALIGN="center">
        <DIV ALIGN="center" STYLE="height:210; width:90%;
            background-color:#99ccff; border:1px solid black">
            <DIV CLASS="bar title">TEXTEditor (TEXTAREA)</DIV> 
	
            <DIV style="padding:10">
                <BUTTON ID="oEditText" TITLE="Turn Editing Off"
	                onclick='fnToggleEdits(oTextarea,oEditText);
                    oTextarea.focus();'>Turn Editing Off</BUTTON>
            </DIV>
   
            <TEXTAREA id=oTextarea ALIGN=left STYLE="height:100; width:95%;
                background-color:white; padding:3; border:inset #99ccff; 
                scrollbar-base-color:#99ccff; overflow=auto;"></TEXTAREA><BR/>
    	    <BUTTON TITLE="Append to HTMLEditor" 
                onclick='oDiv.innerHTML+=oTextarea.value;oTextarea.focus();'>   
                Append to HTMLEditor</BUTTON> 
        </DIV>
    </DIV>
    <BR/>
    <P>Both editors use the same function to activate or deactivate editing. 
        The function uses the <B>isContentEditable</B> property to test whether
        editing is active. Accordingly, the <B>contentEditable</B> property is 
        then reversed to reset editing.</P>
</DIV>
<DIV CLASS="bar" STYLE=" padding:5px; padding-left:10">
    <MSHelp:link xmlns:MSHelp="http://msdn.microsoft.com/mshelp" keywords="msdn_copyright" TABINDEX="0">©  2005  Microsoft Corporation. All rights reserved.</MSHelp:link>
</DIV> 
</body>
</html>
...
Рейтинг: 0 / 0
9 сообщений из 9, страница 1 из 1
Форумы / HTML, JavaScript, VBScript, CSS [игнор отключен] [закрыт для гостей] / Положение курсора в форме ?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]