Autor | Zpráva | ||
---|---|---|---|
davidmyska Profil |
Dobrý den, našel jsem na internetu tento kód pro vkládání BB kódů (původně to bylo vkládání html tagů, ale to jsem si sám předělal), problém je v tom, že po vložení do textarea se kurzor neumístí mezi značky ale za ně a google chrome dokonce před. Předem díky.
<html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=windows-1250" /> <meta http-equiv="Content-Language" content="cs" /> <script type="text/javascript"> function objGet(x) {var d=document;if(typeof x=='string') x=d.getElementById?d.getElementById(x):d.all?d.all[x]:d.layers?d.layers[x]:null; return x;} function objd(x,z) {objGet(x).style.display=z?'block':'none'} function insertAtCursor(myField,myValue0,myValue1,myValue2) { var t=''; //IE support if (document.selection) { myField.focus(); var sel = document.selection.createRange(); if (myValue1!==0) { t=sel.text; if (t=='') t=myValue1; } sel.text = myValue0+t+myValue2; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; if (myValue1!==0) { t=myField.value.substring(startPos,endPos); if (t=='') t=myValue1; } myField.value = myField.value.substring(0, startPos) + myValue0+t+myValue2 + myField.value.substring(endPos, myField.value.length); myField.focus(); } else myField.value += myValue; } function pageAdd(n,m) { var d,t; d=document.f1; t=['','','']; switch (n) { case 1: t[0]='['+m+']';t[2]='[\/'+m+']';break; case 2: t[0]='[URL=www.google.com]';t[1]='Google';t[2]='[\/URL]';break;} insertAtCursor(d.page,t[0],t[1],t[2]) } </script> </head> <body> <form name="f1" action="#"> <center> | <a href="javascript:pageAdd(1,'B')" style="text-decoration: none;"><b>B</b></a> | <a href="javascript:pageAdd(1,'I')" style="text-decoration: none;"><i>I</i></a> | <a href="javascript:pageAdd(1,'U')" style="text-decoration: none;"><u>U</u></a> | <a href="javascript:pageAdd(2)" style="text-decoration: none;">A</a> | <br> <textarea rows="30" cols="50" name="page"></textarea> </form> </body> </html> |
||
davidmyska Profil |
už to mám vyřešené
|
||
Časová prodleva: 12 let
|
0