Problema com .js
Bom, tou com uma dúvidazinha aqui de JavaScript...
Eu fiz um site que tem uma área administrativa cheia de textareas (com names diferentes) na mesma página (editar.php?pagina=blablabla)...
Essa página (editar.php) puxa um .js simples de incluir BBCodes, mais ou menos como aqui no fórum...
A questão é que esse .js usa o nome do textarea várias vezes e, como são vários nomes diferentes, fica dando erro de depuração na página...
Então, a dúvida é como consertar isso...
var theSelection = false;var clientPC = navigator.userAgent.toLowerCase();var clientVer = parseInt(navigator.appVersion);var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1) && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1) && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));var is_mac = (clientPC.indexOf("mac")!=-1);var Bold = 0;var Italic = 0;var Underline = 0;var fc = 0;var fs = 0;var ft = 0;var center = 0;var right = 0;var left = 0;var justify = 0;function storeCaret(textEl) { if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();}function PostWrite(ToAdd) { if (document.post.mensagem.createToAddRange && document.post.mensagem.caretPos) { var caretPos = document.post.mensagem.caretPos; caretPos.text = caretPos.ToAdd.charAt(caretPos.ToAdd.length - 1) == ' ' ? ToAdd + ' ' : ToAdd; document.post.mensagem.focus(); } else { document.post.mensagem.value += ToAdd; document.post.mensagem.focus(); }}function emoticon(text) { if (document.post.mensagem.createTextRange && document.post.mensagem.caretPos) { var caretPos = document.post.mensagem.caretPos; caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text; document.post.mensagem.focus(); } else { document.post.mensagem.value += text; document.post.mensagem.focus(); }}function BBCbold() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<b>" + theSelection + "</b>"; document.post.mensagem.focus(); return; } } if (Bold == 0) { ToAdd = "<b>"; document.post.bold.src = "../images/bold1.gif"; Bold = 1; } else { ToAdd = "</b>"; document.post.bold.src = "../images/bold.gif"; Bold = 0; } PostWrite(ToAdd);}function BBCitalic() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<i>" + theSelection + "</i>"; document.post.mensagem.focus(); return; } } if (Italic == 0) { ToAdd = "<i>"; document.post.italic.src = "../images/italic1.gif"; Italic = 1; } else { ToAdd = "</i>"; document.post.italic.src = "../images/italic.gif"; Italic = 0; } PostWrite(ToAdd);}function BBCunder() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<u>" + theSelection + "</u>"; document.post.mensagem.focus(); return; } } if (Underline == 0) { ToAdd = "<u>"; document.post.under.src = "../images/under1.gif"; Underline = 1; } else { ToAdd = "</u>"; document.post.under.src = "../images/under.gif"; Underline = 0; } PostWrite(ToAdd);}function BBCurl() { var FoundErrors = ''; var enterURL = prompt("Escreva a URL do site", "http://"); var enterTITLE = prompt("Escreva o nome do site", "Nome do site"); if (!enterURL) { FoundErrors += "Você não escreveu a URL"; } if (!enterTITLE) { FoundErrors += "Você não escreveu o nome do site"; } if (FoundErrors) { alert("Erro: "+FoundErrors); return; } var ToAdd = "<a href=\""+enterURL+"\" target=\"_blank\">"+enterTITLE+"</a>"; document.post.mensagem.value+=ToAdd; document.post.mensagem.focus();}function BBCimg() { var FoundErrors = ''; var enterURL = prompt("Escreva a URL da imagem","http://"); if (!enterURL) { FoundErrors += "Você não escreveu a URL da imagem"; } if (FoundErrors) { alert("Erro: "+FoundErrors); return; } var ToAdd = "<img src=\""+enterURL+"\" border=\"0\">"; document.post.mensagem.value+=ToAdd; document.post.mensagem.focus();}function BBCjustify() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<div align=\"justify\">" + theSelection + "</div>"; document.post.mensagem.focus(); return; } } if (justify == 0) { ToAdd = "<div align=\"justify\">"; document.post.justify.src = "../images/justify1.gif"; justify = 1; } else { ToAdd = "</div>"; document.post.justify.src = "../images/justify.gif"; justify = 0; } PostWrite(ToAdd);}function BBCleft() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<div align=\"left\">" + theSelection + "</div>"; document.post.mensagem.focus(); return; } } if (left == 0) { ToAdd = "<div align=\"left\">"; document.post.left.src = "../images/left1.gif"; left = 1; } else { ToAdd = "</div>"; document.post.left.src = "../images/left.gif"; left = 0; } PostWrite(ToAdd);}function BBCright() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<div align=\"right\">" + theSelection + "</div>"; document.post.mensagem.focus(); return; } } if (right == 0) { ToAdd = "<div align=\"right\">"; document.post.right.src = "../images/right1.gif"; right = 1; } else { ToAdd = "</div>"; document.post.right.src = "../images/right.gif"; right = 0; } PostWrite(ToAdd);}function BBCcenter() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<div align=\"center\">" + theSelection + "</div>"; document.post.mensagem.focus(); return; } } if (center == 0) { ToAdd = "<div align=\"center\">"; document.post.center.src = "../images/center1.gif"; center = 1; } else { ToAdd = "</div>"; document.post.center.src = "../images/center.gif"; center = 0; } PostWrite(ToAdd);}function BBCft() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<font face="+document.post.ft.value+">" + theSelection + "</font>"; document.post.mensagem.focus(); return; } } ToAdd = "<font face="+document.post.ft.value+">"+" "+"</font>"; PostWrite(ToAdd);}function BBCfs() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<font size="+document.post.fs.value+">" + theSelection + "</font>"; document.post.mensagem.focus(); return; } } ToAdd = "<font size="+document.post.fs.value+">"+" "+"</font>"; PostWrite(ToAdd);}function BBCfc() { if ((clientVer >= 4) && is_ie && is_win) { theSelection = document.selection.createRange().text; if (theSelection != '') { document.selection.createRange().text = "<font color="+document.post.fc.value+">" + theSelection + "</font>"; document.post.mensagem.focus(); return; } } ToAdd = "<font color="+document.post.fc.value+">"+" "+"</font>"; PostWrite(ToAdd);}Bom, é isso..Espero resposta e feliz ano novo ae.. [http://forum.imasters.com.br/public/style_emoticons/](http://forum.imasters.com.br/public/style_emoticons/)default/natal_happy.gifDiscussão (6)
Carregando comentários...