Post
#1
|
|
|
Grupa: Zarejestrowani Postów: 331 Pomógł: 1 Dołączył: 23.05.2004 Skąd: Tarnów/Londyn Ostrzeżenie: (0%)
|
czesc, mam nastepujacy problem:
selection to zaznaczony tekst w polu pewnym jak dam alert(selection); to zwraca mi część ciągu która jest zaznaczona jak mam zrobic zeby tą część pogrubiło i zapisalo do zmiennej pogrubione ? próbuje: oRTE.document.selection=('<b>' + selection + '</b>'); ale cos nie robi (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) |
|
|
|
![]() |
Post
#2
|
|
|
Grupa: Zarejestrowani Postów: 331 Pomógł: 1 Dołączył: 23.05.2004 Skąd: Tarnów/Londyn Ostrzeżenie: (0%)
|
ok. cala funkcja
Kod //Function to format text in the text box
function FormatText(rte, command, option) { var oRTE; if (document.all) { oRTE = frames[rte]; //get current selected range var selection = oRTE.document.selection; if (selection != null) { rng = selection.createRange(); } } else { oRTE = document.getElementById(rte).contentWindow; //get currently selected range var selection = oRTE.getSelection(); rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange(); } try { if ((command == "forecolor") || (command == "hilitecolor")) { //save current values parent.command = command; currentRTE = rte; //position and show color palette buttonElement = document.getElementById(command + '_' + rte); // Ernst de Moor: Fix the amount of digging parents up, in case the RTE editor itself is displayed in a div. document.getElementById('cp' + rte).style.left = getOffsetLeft(buttonElement, 4) + "px"; document.getElementById('cp' + rte).style.top = (getOffsetTop(buttonElement, 4) + buttonElement.offsetHeight + 4) + "px"; if (document.getElementById('cp' + rte).style.visibility == "hidden") { document.getElementById('cp' + rte).style.visibility = "visible"; document.getElementById('cp' + rte).style.display = "inline"; } else { document.getElementById('cp' + rte).style.visibility = "hidden"; document.getElementById('cp' + rte).style.display = "none"; } } else if (command == "createlink") { var szURL = prompt("Wpisz adres strony:", "http://"); try { //ignore error for blank urls oRTE.document.execCommand("Unlink", false, null); oRTE.document.execCommand("CreateLink", false, szURL); } catch (e) { //do nothing } } else if (command == "createemail") { var szEMAIL = prompt("Wpisz adres email:", "mailto:"); try { //ignore error for blank urls oRTE.document.execCommand("Unlink", false, null); oRTE.document.execCommand("CreateLink", false, szEMAIL); } catch (e) { //do nothing } } else if (command == "uzyjstylu") { ////////////////////////////////////////////////////////////////////////////////////////// oRTE.document.selection.createRange().text.fontsize("20"); ///////////////////////////////////////////////////////////////////////////////////////// } else if (command == "usunstyl") { oRTE.focus(); //oRTE.document.getSelection().style.visibility = "hidden"; var html=oRTE.document.body.innerHTML; var html_male=html.toLowerCase(); start_div_open = html_male.indexOf( "\<div style" ); //zwraca poczatek otwarcia div'a //alert(start_div_open); end_div_open = html_male.indexOf( "\"\>", start_div_open); end_div_open += 2; start_div_close = html_male.lastIndexOf("</div>"); //alert(start_div_close); if (start_div_open!=-1 && start_div_close!=-1) { html=html.substring(end_div_open, start_div_close); oRTE.document.body.innerHTML=html; } oRTE.focus(); } else { oRTE.focus(); oRTE.document.execCommand(command, false, option); oRTE.focus(); } } catch (e) { alert(e); } } |
|
|
|
a79rtur selection 22.10.2004, 20:05:12
revyag Chyba nie chcesz wyświetlić w alercie pogrubinego ... 23.10.2004, 08:10:14
a79rtur nie o to chodzilo, troche namieszałem
kawalek kod... 23.10.2004, 09:00:35
revyag Jeśli chodzi o manipulację własciwościami tekstu, ... 23.10.2004, 10:42:09
a79rtur no nie zupelnie zrobic, potrzebuje do edytora teg... 23.10.2004, 10:48:42
revyag Zmień:
KodoRTE.document.selection.fontsize(... 23.10.2004, 11:08:00
a79rtur to samo 23.10.2004, 11:12:25
revyag A w kiedy masz ten błąd ? Pokaż na przykładzie kod... 23.10.2004, 11:22:55
revyag Tak chyba nie można tego użyć, trzeba to zapisać d... 23.10.2004, 12:08:16
a79rtur to moze by zrobic tak ze mam miejsce w ciagu html ... 23.10.2004, 12:28:06 ![]() ![]() |
|
Aktualny czas: 26.12.2025 - 21:19 |