function EditorDivOpen(a){
$('#'+a).show();
}
function EditorDivFill(a,b){
var init;
if(a == 'smileys'){
init = '<img src="data/img/smileys/sad.png" onclick="EditorTextFill(\':(\');" class="pointer" alt="smiley">
<img src="data/img/smileys/happy.gif" onclick="EditorTextFill(\':)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/angelnot.gif" onclick="EditorTextFill(\'0:=)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/angry.gif" onclick="EditorTextFill(\'=(\');" class="pointer" alt="smiley">
<img src="data/img/smileys/blush.gif" onclick="EditorTextFill(\':@\');" class="pointer" alt="smiley">
<img src="data/img/smileys/cencored.png" onclick="EditorTextFill(\':*\');" class="pointer" alt="smiley">
<img src="data/img/smileys/confused.gif" onclick="EditorTextFill(\':?\');" class="pointer" alt="smiley">
<img src="data/img/smileys/cry.png" onclick="EditorTextFill(\';(\');" class="pointer" alt="smiley">
<img src="data/img/smileys/grin.gif" onclick="EditorTextFill(\':D\');" class="pointer" alt="smiley">
<img src="data/img/smileys/hmm.png" onclick="EditorTextFill(\':|\');" class="pointer" alt="smiley">
<img src="data/img/smileys/hypocrite.gif" onclick="EditorTextFill(\'0=)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/lock.gif" onclick="EditorTextFill(\':x:\');" class="pointer" alt="smiley">
<img src="data/img/smileys/love.gif" onclick="EditorTextFill(\':3\');" class="pointer" alt="smiley">
<img src="data/img/smileys/sunglasses.gif" onclick="EditorTextFill(\'8)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/shifty.gif" onclick="EditorTextFill(\'|)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\'O_o\');" class="pointer" alt="smiley">
<img src="data/img/smileys/shock.gif" onclick="EditorTextFill(\':o\');" class="pointer" alt="smiley">
<img src="data/img/smileys/sweatingbullets.gif" onclick="EditorTextFill(\'^_^\');" class="pointer" alt="smiley">
<img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':p\');" class="pointer" alt="smiley">
<img src="data/img/smileys/tongue.gif" onclick="EditorTextFill(\':P\');" class="pointer" alt="smiley">
<img src="data/img/smileys/wink.gif" onclick="EditorTextFill(\';)\');" class="pointer" alt="smiley">
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xo\');" class="pointer" alt="smiley">
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'XD\');" class="pointer" alt="smiley">
<img src="data/img/smileys/wry.gif" onclick="EditorTextFill(\'xD\');" class="pointer" alt="smiley">';
}
else
{
init = '<b>[b][/b]</b>, <u>[u][/u]</u>, <i>[i][/i]</i>, <s>[s][/s]</s>, [img][/img], [url][/url].';
}
$('#'+b).html(init);
}
<img src="data/img/smileys/happy.gif" alt="smileys" onclick="EditorDivOpen('edit-content'); EditorDivFill('smileys', 'edit-content');" class="pointer">
<div id="edit-content">
</div>
你好又一次stackoverflow!Javascript(jQ)問題:Div不會打開?
我仍在編輯我的論壇軟件。首先是自制的,然後是wysiwyg,現在我正在自己的工作。好吧,沒關係。
我在上面的代碼中得到了一些Javascript錯誤。在IE中的調試器說,「字符串常量未完成」的笑臉在該行的舊標籤的我: init = '<img src="data/img/smileys/sad.png" onclick="EditorTextFill(\':(\');" class="pointer" alt="smiley">
任何進一步的幫助將是不錯的。 Here's also a JsFiddle。
真棒,它的工作!謝謝:) – Thew 2011-03-27 12:38:54
@Thew - 請檢查@ Pointy的建議,一組圖像名稱/編輯器文本數組在這裏非常出色,並且大大減少了您的標記,然後您可以遍歷該數組並創建''元素和分配處理程序。 – 2011-03-27 12:43:50