<?php var clientInfo = navigator.userAgent.toLowerCase(); var isIE = ( clientInfo.indexOf("msie") != -1 ); var isWin = ( (clientInfo.indexOf("win")!=-1) || (clientInfo.indexOf("16bit") != -1) ); function createBBtag( openerTag , closerTag , areaId ) { if(isIE && isWin) { createBBtag_IE( openerTag , closerTag , areaId ); } else { createBBtag_nav( openerTag , closerTag , areaId ); } return; } function createBBtag_IE( openerTag , closerTag , areaId ) { var txtArea = document.getElementById( areaId ); var aSelection = document.selection.createRange().text; if(aSelection) { document.selection.createRange().text = openerTag + aSelection + closerTag; txtArea.focus(); }else { txtArea.value += openerTag + closerTag; txtArea.focus(); } return; } function createBBtag_nav( openerTag , closerTag , areaId ) { var txtArea = document.getElementById( areaId ); if (txtArea.selectionEnd && (txtArea.selectionEnd - txtArea.selectionStart > 0) ) { var preString = (txtArea.value).substring(0,txtArea.selectionStart); var newString = openerTag + (txtArea.value).substring(txtArea.selectionStart,txtArea.selectionEnd) + closerTag; var postString = (txtArea.value).substring(txtArea.selectionEnd); txtArea.value = preString + newString + postString; txtArea.focus(); }else{ var offset = txtArea.selectionStart; var preString = (txtArea.value).substring(0,offset); var newString = openerTag + closerTag; var postString = (txtArea.value).substring(offset); txtArea.value = preString + newString + postString; txtArea.selectionStart = offset + openerTag.length; txtArea.selectionEnd = offset + openerTag.length; txtArea.focus(); } return; } function url(areaId){ var address=prompt("Wpisz adres:", "http://"); if(address!=null && address!=""){ var description=prompt("Tre¶æ odno¶nika:",""); var area=document.getElementById(areaId); if(description==null || description==""){ }else{ }; }else{ alert("Nie wpisale¶ adresu odno¶nika "); }; }; function img(areaId){ var address=prompt("Wpisz adres do zdjêcia:","http://"); if(address!=null && address!=""){ var description=prompt("Opis zdjêcia:",""); var area=document.getElementById(areaId); if(description==null || description==""){ area.value+="[IMG="+address+"]"+address+"[/IMG]"; }else{ area.value+="[IMG="+address+"]"+description+"[/IMG]"; }; }else{ alert("Nie wpisale¶ adresu do zdjêcia "); }; }; ?>
i taki formularz:
teraz tak zmiana czcionki dziala w Operze i w firefoxie a nie dziala w IE i safari znaczy po wybraniu czcionki nic sie nie dzieje. Same skrypty do obejmowania tagiem zaznaczonego tekstu dzialaja tylko nie dzialaja jakby zdarzenia wyboru z listy. Prosilbym o wyjasnienie dlaczego to nie dziala w tej dziadowskiej przegladarce IE i jak zrobic zeby dzialalo. Aha i druga sprawa nie bardzo wiem jak zrobic zeby w miejscu kursora wstawial sie np jakis tekst to znaczy wiedzialbym jak to zrobic zeby dzialao w operze i firefoxie ale nie wiem jak w IE bo ona jakis swoj wlasny javascript
