演示地址:http://bbs.tgszone.com
大家点击[发新帖]按钮后可以看到如下图:
使用方法:
1.在别的地方看到了好的图片贴,帖子内图N多
2.在页面中选中要转贴的图片,按CTRL+C复制
3.按一下本页面的转换按钮(*选择内容复制后不用粘贴到上面的框里,直接按转换按钮即可)
修改方法:
打开post_newthread.htm找到
上面添加
- <script language="JavaScript">
- <!--
- function SymError()
- {
- return true;
- }
- window.onerror = SymError;
- //-->
- </script>
- <script language="JavaScript1.2">
- function html_trans(str) {
- str = str.replace(/\r/g,"");
- str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
- str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");
- str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"\n[url=$1]$2[/url]\n");
- str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"\n[color=$1]$2[/color]\n");
- str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"\n[img]$1[/img]\n");
- str = str.replace(/<([\/]?)b>/ig,"[$1b]");
- str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
- str = str.replace(/<([\/]?)u>/ig,"[$1u]");
- str = str.replace(/<([\/]?)i>/ig,"[$1i]");
- str = str.replace(/ /g," ");
- str = str.replace(/&/g,"&");
- str = str.replace(/"/g,""");
- str = str.replace(/</g,"<");
- str = str.replace(/>/g,">");
- str = str.replace(/<br>/ig,"\n");
- str = str.replace(/<[^>]*?>/g,"");
- str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
- str = str.replace(/\n+/g,"\n");
- return str;
- }
- function trans(){
- var str = "";
- rtf.focus();
- rtf.document.body.innerHTML = "";
- rtf.document.execCommand("paste");
- str = rtf.document.body.innerHTML;
- if(str.length == 0) {
- alert("剪切板不存在超文本数据!");
- return "";
- }
- return html_trans(str);
- }
- </script>
复制代码
然后找到
- <textarea name="message" rows="10" cols="60" style="width:100%; height:350px" tabindex="100" id="{$editorid}_textarea" onSelect="javascript: storeCaret(this);" onClick="javascript: storeCaret(this);" onKeyUp="javascript:storeCaret(this);" onKeyDown="ctlent(event);">$message</textarea>
复制代码
替换为
- <textarea name="message" rows="10" cols="60" style="width:100%; height:350px" tabindex="100" id="{$editorid}_textarea" onSelect="javascript: storeCaret(this);" onClick="javascript: storeCaret(this);" onKeyUp="javascript:storeCaret(this);" onKeyDown="ctlent(event);" onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}">$message</textarea><br /><iframe id="rtf" style="width: 0px; height: 0px;" marginwidth="0" marginheight="0" src="about:blank" scrolling="no"></iframe><label for="x_paste"></label>
复制代码
最后找到
- <input type="button" class="lightbutton" value="{lang post_check_length}" onclick="checklength($('postform'))">
复制代码
在它前面添加
- <input class="lightbutton" name="button" onclick="document.getElementById('{$editorid}_textarea').value += trans()" value="转换剪切板超文本数据" type="button"><script>rtf.document.designMode="On";</script>
复制代码
保存完成。
[ 本帖最后由 mechille 于 2006-11-26 11:53 编辑 ] |