📄 btn.js
字号:
<script language="JavaScript">
function KeyUp (textEl){
if(event.ctrlKey && window.event.keyCode==13 && document.post.Submit.disabled==false)
{
document.post.submit();
document.post.Submit.disabled=true;
}
storeCaret (textEl);
}
function insertstr(NewCode) {
if(document.all){
insertAtCaret(document.post.text, NewCode);
setfocus();
} else{
document.post.text.value += NewCode;
setfocus();
}
}
function storeCaret (textEl){
if(textEl.createTextRange){
textEl.caretPos = document.selection.createRange().duplicate();
}
}
function insertAtCaret (textEl, text){
if (textEl.createTextRange && textEl.caretPos){
var caretPos = textEl.caretPos;
caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text;
} else if(textEl) {
textEl.value += text;
} else {
textEl.value = text;
}
}
function btn_b() {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[b]" + range.text + "[/b]";
}
else {
txt=prompt("粗体文字:","粗体文字");
if (txt!=null) {
AddTxt="[b]"+txt;
insertstr(AddTxt);
insertstr("[/b]");
}
}
}
function btn_u() {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[u]" + range.text + "[/u]";
}
else {
txt=prompt("下划线文字:","下划线文字");
if (txt!=null) {
AddTxt="[u]"+txt;
insertstr(AddTxt);
insertstr("[/u]");
}
}
}
function btn_i() {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[i]" + range.text + "[/i]";
}
else {
txt=prompt("斜体文字:","斜体文字");
if (txt!=null) {
AddTxt="[i]"+txt;
insertstr(AddTxt);
insertstr("[/i]");
}
}
}
function btn_url() {
txt2=prompt("链接显示:\n如果置空则表示直接显示链接地址","");
if (txt2!=null) {
txt=prompt("请输入 URL:","http://");
if (txt!=null) {
if (txt2=="") {
AddTxt="[url]"+txt;
insertstr(AddTxt);
insertstr("[/url]");
} else {
AddTxt="[url="+txt+"]"+txt2;
insertstr(AddTxt);
insertstr("[/url]");
}
}
}
}
function btn_img()
{
txt=prompt("图片的URL地址:","http://");
if(txt!=null)
{
AddTxt="\r[img]"+txt;
insertstr(AddTxt);
insertstr("[/img]");
}
}
function btn_code() {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[code]" + range.text + "[/code]";
}
else {
txt=prompt("代码内容:","");
if (txt!=null) {
AddTxt="\r[code]"+txt;
insertstr(AddTxt);
insertstr("[/code]");
}
}
}
function btn_swf()
{
txt=prompt("Flash动画的URL地址:","http://");
if(txt!=null)
{
AddTxt="\r[swf]"+txt;
insertstr(AddTxt);
insertstr("[/swf]");
}
}
function btn_mp()
{
txt=prompt("Windows Media Player文件的URL地址:","http://");
if(txt!=null)
{
AddTxt="\r[mp]"+txt;
insertstr(AddTxt);
insertstr("[/mp]");
}
}
function btn_rm()
{
txt=prompt("RealPlayer文件的URL地址:","http://");
if(txt!=null)
{
AddTxt="\r[rm]"+txt;
insertstr(AddTxt);
insertstr("[/rm]");
}
}
function btn_q() {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[quote]" + range.text + "[/quote]";
}
else {
txt=prompt("引用内容:","文字");
if(txt!=null) {
AddTxt="\r[quote]\r"+txt;
insertstr(AddTxt);
insertstr("\r[/quote]");
}
}
}
function showcolor(color) {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[color=" + color + "]" + range.text + "[/color]";
}
else {
txt=prompt("文字颜色:"+color,"文字");
if(txt!=null) {
AddTxt="[color="+color+"]"+txt;
insertstr(AddTxt);
insertstr("[/color]");
}
}
}
function showsize(size) {
if (document.selection && document.selection.type == "Text") {
var range = document.selection.createRange();
range.text = "[size=" + size + "]" + range.text + "[/size]";
}
else {
txt=prompt("文字大小:"+ size,"文字");
if (txt!=null) {
AddTxt="[size="+size+"]"+txt;
insertstr(AddTxt);
insertstr("[/size]");
}
}
}
function setfocus() {
document.post.text.focus();
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -