UBB(JS完整版)

來源:互聯網
上載者:User

 <SCRIPT language=JavaScript1.2 defer>
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(/<style[^>]*?>([\w\W]*?)<\/stylet>/ig,"");
 str = str.replace(/<embed[^>]*?>([\w\W]*?)<\/embed>/ig,"");
 
 str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"[url=$1]$2[/url]");
 str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
 str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"[img]$1[/img]");
 str = str.replace(/<param NAME="Movie" value="([^>"]+\.swf)"[^>]*>/ig,"[flash]$1[/flash]");
 
 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(/&nbsp;/g," ");
 str = str.replace(/&amp;/g,"&");
 str = str.replace(/&quot;/g,"\"");
 str = str.replace(/&lt;/g,"<");
 str = str.replace(/&gt;/g,">");

        str = str.replace(/\[url=([^\]]+)\]\[img\]/g,"[img]");
        str = str.replace(/\[\/img\]\[\/url\]/g,"[/img]");

 str = str.replace(/<br>/ig,"\n");
 str = str.replace(/<[^>]*?>/g,"");

 

 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;
 document.all.text2.value=str;
 if(str.length == 0) {
  alert("剪下版不存在超文本資料!");
  return "";
 }
 return html_trans(str);
}

      </SCRIPT> 

<TEXTAREA class=input2 id=text style="WIDTH: 100%; HEIGHT: 200px" rows="1" cols="20"></TEXTAREA><BR>

<IFRAME id=rtf style="WIDTH: 720px; HEIGHT: 100px" marginWidth=0 marginHeight=0
      src="about:blank" scrolling=yes name="I1"></IFRAME>

<INPUT class=input1 onclick="document.getElementById('text').value = trans()" type=button value=轉換剪下板資料>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.