<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title>111</title> <script language=JavaScript> function Insert(Text) { element = document.getElementById("texts"); element.focus(); if (document.selection) { SelectedText = element.document.selection.createRange(); SelectedText.text = Text; } } </script> </head> <body> <textarea name=texts rows=5 cols=26>бла бла бла</textarea> <br> Написать: <input type=text name=paste> <br> Вставить: <input type=button value='Вставить' onclick='Insert(paste.value)'> </body> </html>
<script language=JavaScript> function Insert(Text) { var obj = document.getElementsByName("texts")[0]; obj.focus(); var pos1 = obj.selectionStart, pos2 = obj.selectionEnd; if(typeof(pos1)=="number") { obj.value = obj.value.substring(0, pos1) + Text + obj.value.substring(pos2, obj.value.length); var pos3=pos1+Text.length; obj.setSelectionRange(pos3,pos3); } else if (document.selection) { SelectedText=document.selection.createRange(); SelectedText.text=Text; SelectedText.select(); } } </script> <a href="javascript:;" onclick="Insert('Text1')" title="1"><img src=kartinka1.gif></a> <a href="javascript:;" onclick="Insert('Text2')" title="2"><img src=kartinka2.gif></a> <a href="javascript:;" onclick="Insert('Text3')" title="3"><img src=kartinka3.gif></a>
onfocus="this.value='';" value="Текс который при наведении убирается"
<script language=JavaScript> function Insert(Text) { var obj = document.getElementsByName("texts")[0]; obj.focus(); var pos1 = obj.selectionStart, pos2 = obj.selectionEnd; if(typeof(pos1)=="number") { obj.value = obj.value.substring(0, pos1) + Text + obj.value.substring(pos2, obj.value.length); var pos3=pos1+Text.length; obj.setSelectionRange(pos3,pos3); } else if (document.selection) { SelectedText=document.selection.createRange(); SelectedText.text=Text; SelectedText.select(); } } </script>
<a href="javascript:;" onclick="Insert('Text1')" title="1">Text1</a> <a href="javascript:;" onclick="Insert('Text2')" title="2">Text2</a>
<script language=JavaScript> function Insert(Text) { var obj = document.getElementsByName("texts")[0]; obj.focus(); var pos1 = obj.selectionStart, pos2 = obj.selectionEnd; if(typeof(pos1)=="number") { obj.value = obj.value.substring(0, pos1) + Text + obj.value.substring(pos2, obj.value.length); var pos3=pos1+Text.length; obj.setSelectionRange(pos3,pos3); } else if (document.selection) { SelectedText=document.selection.createRange(); SelectedText.text=Text; SelectedText.select(); } } function ftags(t1,t2) { var obj=document.getElementsByName("texts")[0]; obj.focus(); var pos1 = obj.selectionStart, pos2 = obj.selectionEnd; if(typeof(pos1)=="number") { obj.value = obj.value.substring(0, pos1) + t1 + obj.value.substring(pos1, pos2) + t2 + obj.value.substring(pos2, obj.value.length); var pos3=pos2+t1.length+t2.length; obj.setSelectionRange(pos3,pos3); } else if(document.selection) { var range=document.selection.createRange(); range.text=t1+range.text+t2; range.select(); } else obj.value += t1 + t2; obj.focus(); } </script> <a href="javascript:;" onclick="Insert('Text1')" title="1">Text1</a> <a href="javascript:;" onclick="Insert('Text2')" title="2">Text2</a> <a href='javascript:ftags("[b]","[/b]");' title="3">B</a> <textarea name="texts" rows="10" cols="75" tabindex="1"></textarea>