Не работает скрипт
Не работает в FireFox следующий скрипт редактора.
Помогите, не пойму почему!
<script language="JavaScript">
function url_paste(form, a)
{
theSelection = document.selection.createRange().text; // Фyнкция выдeлeния тeкcтa
if(theSelection)
{
switch(a)
{
case 1:
document.selection.createRange().text = "<b>"+theSelection+"</b>";
break;
case 2:
document.selection.createRange().text = "<i>"+theSelection+"</i>";
break;
case 3:
document.selection.createRange().text = "<u>"+theSelection+"</u>";
break;
case 4:
document.selection.createRange().text = "<s>"+theSelection+"</s>";
break;
case 5:
document.selection.createRange().text = "<sup>"+theSelection+"</sup>";
break;
case 6:
document.selection.createRange().text = "<sub>"+theSelection+"</sub>";
break;
case 7:
document.selection.createRange().text = "<p align=left>"+theSelection+"</p>\n";
break;
case 8:
document.selection.createRange().text = "<p align=center>"+theSelection+"</p>\n";
break;
case 9:
document.selection.createRange().text = "<p align=right>"+theSelection+"</p>\n";
break;
case 10:
document.selection.createRange().text = "<p align=justify>"+theSelection+"</p>\n";
break;
case 11:
document.selection.createRange().text = "<h1>"+theSelection+"</h1>\n";
break;
case 12:
document.selection.createRange().text = "<h2>"+theSelection+"</h2>\n";
break;
case 13:
document.selection.createRange().text = "<h3>"+theSelection+"</h3>\n";
break;
case 14:
document.selection.createRange().text = "<p>"+theSelection+"</p>\n";
break;
case 15:
txt=prompt("Адрес.","http://");
if(txt!=null)
{
AddTxt="<a href="+txt+">";
AddTxt+=theSelection+"</a>";
}
document.selection.createRange().text = AddTxt;
break;
case 16:
document.selection.createRange().text = theSelection+"<hr>\n";
break;
case 17:
form.descr.document.execCommand('undo', false, '');
form.descr.document.focus();
break;
case 18:
form.descr.document.execCommand('redo', false, '');
form.descr.document.focus();
break;
case 19:
form.descr.document.execCommand('cut', false);
break;
case 20:
form.descr.document.execCommand('copy', false);
break;
case 21:
form.descr.focus();
form.descr.document.execCommand('paste', false);
break;
}
form.descr.focus();
}
else
{
switch(a)
{
case 1:
form.descr.value+="<b>";
break;
case 2:
form.descr.value+="<i>";
break;
case 3:
form.descr.value+="<u>";
break;
case 4:
form.descr.value+="<s>";
break;
case 5:
form.descr.value+="<sup>";
break;
case 6:
form.descr.value+="<sub>";
break;
case 7:
form.descr.value+="<p align=left>";
break;
case 8:
form.descr.value+="<p align=center>";
break;
case 9:
form.descr.value+="<p align=right>";
break;
case 10:
form.descr.value+="<p align=justify>";
break;
case 11:
form.descr.value+="<h1>";
break;
case 12:
form.descr.value+="<h2>";
break;
case 13:
form.descr.value+="<h3>";
break;
case 14:
form.descr.value+="<p>";
break;
case 15:
txt=prompt("Адрес.","http://");
if(txt!=null)
{
AddTxt="<a href="+txt+">";
txt=prompt("Текст, который будет ссылкой","Текст");
AddTxt+=txt+"</a>";
}
form.descr.value+=AddTxt;
break;
case 16:
form.descr.value+="\n<hr>\n";
break;
case 17:
form.descr.document.execCommand('undo', false, '');
break;
case 18:
form.descr.document.execCommand('redo', false, '');
break;
case 19:
form.descr.document.execCommand('cut', false);
break;
case 20:
form.descr.document.execCommand('copy', false);
break;
case 21:
form.descr.focus();
form.descr.document.execCommand('paste', false);
break;
}
form.descr.focus();
}
}
function viewpred(form)
{
msg=open("","DisplayWindow","status=1,scrollbars=1 ");msg.document.write(form.descr.value);
}
</script>
<?php
echo "<td align=\"center\" style=\"text-align:center;\">
<table border=\"0\" style=\"border-style:none; text-align:center;\"><tr>
<td align=center nowrap >
<button style=\"width=25; height=25\" align=\"center\" title=\"Отменить\" onclick=\"url_paste(this.form, 17)\"><img src=\"image/undo.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Повторить\" onclick=\"url_paste(this.form, 18)\"><img src=\"image/redo.gif\"></button>
</td><td align=center nowrap>
<button style=\"width=25; height=25\" align=\"center\" title=\"Вырезать\" onclick=\"url_paste(this.form, 19)\"><img src=\"image/cut.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Копировать\" onclick=\"url_paste(this.form, 20)\"><img src=\"image/copy.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Вставить\" onclick=\"url_paste(this.form, 21)\"><img src=\"image/paste.gif\"></button>
</td><td align=center nowrap>
<button style=\"width=25; height=25\" align=\"center\" title=\"Параграф\" onclick=\"url_paste(this.form, 14)\"><p align=center><b>p</b></p></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"H1\" onclick=\"url_paste(this.form, 11)\"><p align=center><b>H1</b></p></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"H2\" onclick=\"url_paste(this.form, 12)\"><p align=center><b>H2</b></p></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"H3\" onclick=\"url_paste(this.form, 13)\"><p align=center><b>H3</b></p></button>
</td><td align=center nowrap>
<button style=\"width=25; height=25\" align=\"center\" title=\"Полужирный\" onclick=\"url_paste(this.form, 1)\" ><img src=\"image/b.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Курсив\" onclick=\"url_paste(this.form, 2)\"><img src=\"image/i.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Подчеркнутый\" onclick=\"url_paste(this.form, 3)\"><img src=\"image/u.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Перечеркнутый\" onclick=\"url_paste(this.form, 4)\"><img src=\"image/s.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Степень\" onclick=\"url_paste(this.form, 5)\" ><img src=\"image/sup.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Индекс\" onclick=\"url_paste(this.form, 6)\" ><img src=\"image/sub.gif\"></button>
</td><td align=center nowrap>
<button style=\"width=25; height=25\" align=\"center\" title=\"По левому краю\" onclick=\"url_paste(this.form, 7)\" ><img src=\"image/l.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"По центру\" onclick=\"url_paste(this.form, 8)\" ><img src=\"image/c.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"По правому краю\" onclick=\"url_paste(this.form, 9)\" ><img src=\"image/r.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"По ширине\" onclick=\"url_paste(this.form, 10)\" ><img src=\"image/j.gif\"></button>
</td><td align=center nowrap>
<button style=\"width=25; height=25\" align=\"center\" title=\"Гиперссылка\" onclick=\"url_paste(this.form, 15)\" ><img src=\"image/a.gif\"></button>
<button style=\"width=25; height=25\" align=\"center\" title=\"Линия\" onclick=\"url_paste(this.form, 16)\" ><img src=\"image/hr.gif\"></button>
<a href=\"edit/addtable.php\" target=\"_blank\"><img src=\"image/tab.gif\" title=\"Вставить таблицу\" border=0></a>
<a href=\"edit/addpicture.php\" target=\"_blank\"><img src=\"image/addimage.gif\" title=\"Загрузить картинку\" border=0></a>
</td><td align=center nowrap>
<a href=\"edit/edit/index.html\" target=\"_blank\"><p>Сгенерировать HTML-код</a>
</td><td align=right nowrap width=100%>
</td>
</tr></table>";
?>
|