手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >教学演示-UBB,剪贴板,textRange及其他
教学演示-UBB,剪贴板,textRange及其他
摘要:这是一个给新手学习代码的帖子,包含以下内容:如何使用UBB代码,如何用js与剪贴板交互,如何使用textRange对象,如何使用自定义的快捷...

这是一个给新手学习代码的帖子,包含以下内容:

如何使用UBB代码,如何用js与剪贴板交互,如何使用textRange对象,如何使用自定义的快捷键操作,如何自动随窗口大小调整页面内容尺寸,正则表达式的使用等等

请仔细阅读代码,有问题请提问,目前代码开发完成度80%,IEonly

Blue Idea UBB Code Edit * { margin:0px; padding:0px; } html, body { background-color:buttonface; width:100%; height:100%; overflow:hidden; border-width:0px; font-size:13px; font-family:Verdana Arial 宋体; color:#333333; cursor:default; } input {border-width:1px;} #divMain { overflow:hidden; } #divTools { width:100%; height:20px; line-height:20px; overflow:hidden; border-bottom:1px solid buttonshadow; margin:0px; padding:0px; padding-left:10px; background-color:buttonface; color:black; } #divTools label { font-weight:bold;float:left;padding-left:15px;padding-right:15px;} #divTools a { display:block; float:left; height:20px; padding-left:15px; padding-right:15px; line-height:20px; text-align:center; overflow:hidden; color:black; text-decoration:none; } #divTools a:hover {background-color:gold;color:black;} #divTools a:active {background-color:navy;color:white;} #divContent, #txtContent { border:1px inset buttonface; width:94%; height:400px; overflow:auto; padding:5px; margin:2px 15px 0px 15px; background-color:white; color:black; display:none; } #txtContent { font-size:14px; border-width:1px; display:block; } .UBB_code { border:1px solid #555; padding:10px; margin:10px; width:500px; background-color:#DDD; font-size:13px; font-weight:normal; color:black; } .UBB_html { padding:4px; width:350px; height:200px; font-size:13px; font-weight:normal; color:black; } .UBB_html_button { width:100px; height:22px; line-height:18px; border-width:2px; margin:0px; } var txtContent, divContent, viewButton01, viewButton02, dtf; var strHTMLStart=""; var strHTMLEnd=""; var strCodeStart=""; var strCodeEnd=""; function init(){ txtContent=document.getElementById("txtContent"); divContent=document.getElementById("divContent"); viewButton01=document.getElementById("viewButton01"); viewButton02=document.getElementById("viewButton02"); dtfFrame=document.createElement("iframe"); dtfFrame.frameBorder="0px"; dtfFrame.style.width="0px"; dtfFrame.style.height="0px"; document.body.appendChild(dtfFrame); dtf=window.frames[window.frames.length-1]; dtf.location.href="about:blank"; window.onresize=switchModel; txtContent.onkeydown=chkKey; switchModel(0); } function switchModel(id){ // 重新计算输入区域大小 txtContent.style.width=document.body.clientWidth-50+"px"; txtContent.style.height=document.body.clientHeight-50+"px"; divContent.style.width=document.body.clientWidth-50+"px"; divContent.style.height=document.body.clientHeight-50+"px"; if(id==0){ // 转到代码视图 divContent.style.display="none"; txtContent.style.display="block"; viewButton01.style.backgroundColor="navy"; viewButton01.style.color="white"; viewButton02.style.backgroundColor=""; viewButton02.style.color=""; txtContent.focus(); }else if(id==1){ // 转到预览视图 divContent.style.display="block"; txtContent.style.display="none"; divContent.innerHTML=UBB2HTML(txtContent.value); viewButton02.style.backgroundColor="navy"; viewButton02.style.color="white"; viewButton01.style.backgroundColor=""; viewButton01.style.color=""; divContent.focus(); } } function HTML2UBB(strHTML){ var re=htmlDecode(strHTML); re=re.replace(//ig,"[$1b]"); re=re.replace(//ig,"[$1b]"); re=re.replace(//ig,"[$1i]"); re=re.replace(//ig,"[$1i]"); re=re.replace(/< *(/?) *div[wW]*?>/ig,"rn"); re=re.replace(/< *img +[wW]*?src=["]?([^">rn]+)[wW]*?>/ig,"[img]$1[/img]"); re=re.replace(/< *a +[wW]*?href=["]?([^">rn]+)[wW]*?>([wW]*?)< */ *a *>/ig,"[url=$1]$2[/url]"); re=re.replace(/

【教学演示-UBB,剪贴板,textRange及其他】相关文章:

js常用函数 不错

让iframe框架网页在任何浏览器下自动伸缩

利用js实现禁止复制文本信息

javascript实现查找数组中最大值方法汇总

点此处秒后立即下载

简介JavaScript中用于处理正切的Math.tan()方法

JavaScript实现点击自动选择TextArea文本的方法

JavaScript中for循环的使用详解

多个iframe自动调整大小的问题

Javascript动态创建表格及删除行列的方法

精品推荐
分类导航