- Katılım
- 11 Temmuz 2008
- Mesajlar
- 18
- Reaction score
- 0
Birkaç fonksiyon bulup basit bir metin editörü yapmaya çalıştım. Birkaç şey sormak istiyorum, yardımcı olabilir misiniz?
SORUN 1: Yazı tipi ve Büyüklük seçenekleri firefox ve operada çalışıyor ancak internet explorerda seçim yaptığımda hiçbir tepki vermiyor.
SORUN 2: Renk paletini yeni bir sayfa açtırmak süretiyle yapabildim. Gizli bir iframe oluşturup Renk linkine tıklandığında görünür hale gelmesi gibi bir şey yapılabilir mi? Bikaç deneme yaptım ama başaramadım. Yani renk linkine tıklandığında hemen linkin altına bir pencere sayfa üzerinde açıp renkleri oradan nasıl seçtirebilirim?
SORUN 3: Yazılar textarea içerisinde kod olarak görünüyor(
gibi...). Bunun yerine orada normal html şeklini(yani yazı değeri koyu görünecek) nasıl gösterebilirim?
editor.htm
palet.htm
İndirip görebileceğiniz link: http://rapidshare.com/files/128684899/editor.rar.html
SORUN 1: Yazı tipi ve Büyüklük seçenekleri firefox ve operada çalışıyor ancak internet explorerda seçim yaptığımda hiçbir tepki vermiyor.
SORUN 2: Renk paletini yeni bir sayfa açtırmak süretiyle yapabildim. Gizli bir iframe oluşturup Renk linkine tıklandığında görünür hale gelmesi gibi bir şey yapılabilir mi? Bikaç deneme yaptım ama başaramadım. Yani renk linkine tıklandığında hemen linkin altına bir pencere sayfa üzerinde açıp renkleri oradan nasıl seçtirebilirim?
SORUN 3: Yazılar textarea içerisinde kod olarak görünüyor(
PHP:
[b]yazı[/b]
editor.htm
Kod:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Editör</title>
</head>
<body>
<form action="editor.htm" method="post" name="bolum">
<script language="javascript">
// Replaces the currently selected text with the passed text.
function replaceText(text, textarea)
{
// Attempt to create a text range (IE).
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
var caretPos = textarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
caretPos.select();
}
// Mozilla text range replace.
else if (typeof(textarea.selectionStart) != "undefined")
{
var begin = textarea.value.substr(0, textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var scrollPos = textarea.scrollTop;
textarea.value = begin + text + end;
if (textarea.setSelectionRange)
{
textarea.focus();
textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
}
textarea.scrollTop = scrollPos;
}
// Just put it on the end.
else
{
textarea.value += text;
textarea.focus(textarea.value.length - 1);
}
}
// Surrounds the selected text with text1 and text2.
function surroundText(text1, text2, textarea)
{
// Can a text range be created?
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
var caretPos = textarea.caretPos, temp_length = caretPos.text.length;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
if (temp_length == 0)
{
caretPos.moveStart("character", -text2.length);
caretPos.moveEnd("character", -text2.length);
caretPos.select();
}
else
textarea.focus(caretPos);
}
// Mozilla text range wrap.
else if (typeof(textarea.selectionStart) != "undefined")
{
var begin = textarea.value.substr(0, textarea.selectionStart);
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var newCursorPos = textarea.selectionStart;
var scrollPos = textarea.scrollTop;
textarea.value = begin + text1 + selection + text2 + end;
if (textarea.setSelectionRange)
{
if (selection.length == 0)
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
else
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
textarea.focus();
}
textarea.scrollTop = scrollPos;
}
// Just put them on the end, then.
else
{
textarea.value += text1 + text2;
textarea.focus(textarea.value.length - 1);
}
}
function renk() { window.open("palet.htm","yeni_pencere", "width=150,height=100");} // Renk paletini aç
</script>
<select>
<option selected="selected">Yazı Tipi</option>
<option onclick="surroundText('[font=arial]', '[/font]', document.forms.bolum.icerik);">Arial</option>
<option onclick="surroundText('[font=times]', '[/font]', document.forms.bolum.icerik);">Times New Roman</option>
</select>
<select>
<option selected="selected">Büyüklük</option>
<option onclick="surroundText('[size=1]', '[/size]', document.forms.bolum.icerik);">1</option>
<option onclick="surroundText('[size=2]', '[/size]', document.forms.bolum.icerik);">2</option>
</select>
<a href="#" onClick="renk();">Renk</a> -
<a href="javascript:void(0);" onclick="replaceText(' :)', document.forms.bolum.icerik);">Gülücük</a><br>
<a href="javascript:void(0);" onclick="surroundText('[b]', '[/b]', document.forms.bolum.icerik);" >Kalın</a> -
<a href="javascript:void(0);" onclick="surroundText('[i]', '[/i]', document.forms.bolum.icerik);" >İtalik</a> -
<a href="javascript:void(0);" onclick="surroundText('[u]', '[/u]', document.forms.bolum.icerik);" >Altı Çizili</a> |
<a href="javascript:void(0);" onclick="yol = prompt('Adres','http://'); surroundText('[link='+yol+']', '[/link]', document.forms.bolum.icerik);">Link</a>
<a href="javascript:void(0);" onclick="resim = prompt('Adres','http://'); replaceText('[resim]'+resim+'[/resim]', document.forms.bolum.icerik);">Resim</a>
<br>
<textarea name="icerik" cols="60" rows="15"></textarea>
<br>
<input type="submit" value="ekle">
</form>
</body>
</html>
Kod:
<html><head><title>Renk Paleti</title></head>
<body leftmargin=0 topmargin=0 bottommargin=0 rightmargin=0>
<table width="150" height="100" cellpadding="0" cellspacing="1" border="1" align="center">
<tr>
<td id="#FFFFFF" bgcolor="#FFFFFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCCCC" bgcolor="#FFCCCC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCC99" bgcolor="#FFCC99" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFFF99" bgcolor="#FFFF99" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFFFCC" bgcolor="#FFFFCC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#99FF99" bgcolor="#99FF99" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#99FFFF" bgcolor="#99FFFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CCFFFF" bgcolor="#CCFFFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CCCCFF" bgcolor="#CCCCFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCCFF" bgcolor="#FFCCFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#CCCCCC" bgcolor="#CCCCCC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF6666" bgcolor="#FF6666" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF9966" bgcolor="#FF9966" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFFF66" bgcolor="#FFFF66" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFFF33" bgcolor="#FFFF33" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#66FF99" bgcolor="#66FF99" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#33FFFF" bgcolor="#33FFFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#66FFFF" bgcolor="#66FFFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#9999FF" bgcolor="#9999FF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF99FF" bgcolor="#FF99FF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#C0C0C0" bgcolor="#C0C0C0" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF0000" bgcolor="#FF0000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF9900" bgcolor="#FF9900" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCC66" bgcolor="#FFCC66" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFFF00" bgcolor="#FFFF00" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#33FF33" bgcolor="#33FF33" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#66CCCC" bgcolor="#66CCCC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#33CCFF" bgcolor="#33CCFF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#6666CC" bgcolor="#6666CC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CC66CC" bgcolor="#CC66CC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#999999" bgcolor="#999999" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CC0000" bgcolor="#CC0000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FF6600" bgcolor="#FF6600" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCC33" bgcolor="#FFCC33" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#FFCC00" bgcolor="#FFCC00" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#33CC00" bgcolor="#33CC00" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#00CCCC" bgcolor="#00CCCC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#3366FF" bgcolor="#3366FF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#6633FF" bgcolor="#6633FF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CC33CC" bgcolor="#CC33CC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#666666" bgcolor="#666666" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#990000" bgcolor="#990000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CC6600" bgcolor="#CC6600" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#CC9933" bgcolor="#CC9933" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#999900" bgcolor="#999900" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#009900" bgcolor="#009900" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#339999" bgcolor="#339999" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#3333FF" bgcolor="#3333FF" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#6600CC" bgcolor="#6600CC" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#993399" bgcolor="#993399" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#333333" bgcolor="#333333" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#660000" bgcolor="#660000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#993300" bgcolor="#993300" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#996633" bgcolor="#996633" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#666600" bgcolor="#666600" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#006600" bgcolor="#006600" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#336666" bgcolor="#336666" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#000099" bgcolor="#000099" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#333399" bgcolor="#333399" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#663366" bgcolor="#663366" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
<tr>
<td id="#000000" bgcolor="#000000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#330000" bgcolor="#330000" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#663300" bgcolor="#663300" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#663333" bgcolor="#663333" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#333300" bgcolor="#333300" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#003300" bgcolor="#003300" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#003333" bgcolor="#003333" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#000066" bgcolor="#000066" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#330099" bgcolor="#330099" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
<td id="#330033" bgcolor="#330033" width="10" height="10" onclick="javascript:window.opener.surroundText('[color=#FFFFFF]', '[/color]', window.opener.document.forms.bolum.icerik);"><img width="1" height="1"></td>
</tr>
</table>
</body></html>
İndirip görebileceğiniz link: http://rapidshare.com/files/128684899/editor.rar.html