聊天常用js代碼

<script language='javascript'>
//轉意義字符與替換圖象以及字體HtmlEncode(text)
function HtmlEncode(text)
{
return text.replace(//"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/#br#/g,'<br>').replace(/IMGSTART/g,'<IMG style=').replace(/IMGMID/g,' src=').replace(/IMGEND/g,'>').replace(/FONTSTART/g,'<font? style=/"').replace(/FONTEND/g,'</font>').replace(/FONTSTYLEEND/g,'/">').replace(/FORUELSTARTMA/g,'<a target=_blank href=').replace(/FORUELENDMA/g,'</a>').replace(/NIFORPIEHAO/g,'&#39;');
}
//打印scrolldIV這個div的內碼內容getcontent()
function getcontent()
{
document.write(document.getElementById("scrolldIV").innerText);
}
//保存咨詢記錄函數CmdSave()
function CmdSave()
{
var OW = window.open('','','');
var DD = new Date();
OW.document.open();
OW.document.write(document.getElementById("scrolldIV").innerHTML);
OW.document.execCommand ("SaveAs",true,"咨詢記錄-"+ DD.getYear() + "-" + DD.getMonth() + "-" + DD.getDate() + "-" + DD.getHours() + "-" + DD.getMinutes() +".htm");
OW.close();
}
//把用戶列表加載入到scrolldIV,函數輸入值為用戶列表ChatText(Text)
function ChatText(Text)
{
if(Text!="")
??? {
???? document.getElementById('scrolldIV').innerHTML=document.getElementById('scrolldIV').innerHTML+ HtmlEncode(Text);
???? window.form1.ScrolldNeirong.value=document.getElementById('scrolldIV').innerHTML;
??? document.getElementById('scrolldIV').scrollTop = document.getElementById('scrolldIV').scrollHeight;document.form1.TextBox1.focus();
??? }
??? if(document.getElementById('scrolldIV').scrollTop>=2000)
??? {
??? Cls();
??? }
}
//UserList
//把咨詢記錄加載入到UserList,函數輸入值為咨詢所發送的記錄UserListAdd(Text)
function UserListAdd(text,ctext,soundstat)
{

var listinfo=text.toString().replace(/ListUsersStart/g, "<label οnmοuseοver=this.style.cursor='hand'; οnclick=window.form1.ToUser.value='").replace(/ListUsersMidA/g,"';document.getElementById('ToUserType').innerHTML='").replace(/ListUsersMid/g, "';onMouseOut=this.style.cursor='default'; >").replace(/ListUsersEnd/g, "</label><br>");
var clistinfo=ctext.toString().replace(/ListUsersStart/g, "<label οnmοuseοver=this.style.cursor='hand'; οnclick=window.form1.ToUser.value='").replace(/ListUsersMidA/g,"';document.getElementById('ToUserType').innerHTML='").replace(/ListUsersMid/g, "';onMouseOut=this.style.cursor='default'; >").replace(/ListUsersEnd/g, "</label><br>");
document.getElementById('UserList').innerHTML=listinfo+'---以上為管理員---<br>'+clistinfo;
if(soundstat==1)
{
Sound.play('sound/come.wav');
}
if(soundstat==2)
{
Sound.play('sound/go.wav');
}
}

//清屏Cls()
function Cls()
{
document.getElementById('scrolldIV').innerHTML="";

}
// 隱藏與顯示部分的層1為顯示0為隱藏showOrHide(value)
function showOrHide(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer1"].visibility='hide';
??????? else
?????????? document.all["Layer1"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer1"].visibility='show';
?????? else
????????? document.all["Layer1"].style.visibility='visible';
?? }
}
function showOrHide1(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer2"].visibility='hide';
??????? else
?????????? document.all["Layer2"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer2"].visibility='show';
?????? else
????????? document.all["Layer2"].style.visibility='visible';
?? }
}

function showOrHide2(value) {
??? if (value==0) {
??????? if (document.layers)
?????????? document.layers["Layer3"].visibility='hide';
??????? else
?????????? document.all["Layer3"].style.visibility='hidden';
?? }
?? else if (value==1) {
?????? if (document.layers)
????????? document.layers["Layer3"].visibility='show';
?????? else
????????? document.all["Layer3"].style.visibility='visible';
?? }
}

//更改字體大小屬性的函數changeSize(obj)
function changeSize(obj){
document.getElementById("TextBox1").style.fontSize = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;

}
//更改字體屬性的函數changeFont(obj)
function changeFont(obj){
document.getElementById("TextBox1").style.fontFamily = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;

}
//更改字體顏色屬性的函數changeColors(obj)
function changeColors(obj){
document.getElementById("TextBox1").style.color = obj.value;
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;

}

//加載表情圖象,輸入值為圖象的路徑selImg(text)
function selImg(text){
var newElem = document.createElement("IMG");
newElem.src=text;
newElem.style.cssText="WIDTH:19;HEIGHT:19";

//newElem.οnlοad="javascript:AutoAdjustAtchImgSize(this,600);
//for(var i=0;i<5;i++)
window.form1.TextBox1.appendChild(newElem);

}

//把TextArea(TextBox1)的值賦個隱藏控件(TextBox1Hide)激發button1單擊事件
function typechild()
{
if(document.form1.TextBox1.innerHTML.length<1)
?{
???? alert("咨詢內容不能為空!");
???? return false;
?}
?if(document.form1.ToUser.value.length<1)
?{
? alert("咨詢對象未選中!");
???? return false;
?}

window.form1.TextBox1Hide.value= UrlChange(window.form1.TextBox1.innerHTML);
window.form1.TextBox1cssText.value=window.form1.TextBox1.style.cssText;
document.getElementById('Button1').click();
//alert(window.form1.TextBox1cssText.value);
}
//輸入方式onkepress時判斷咨詢字符是否超過1000
?function regInput(obj, reg, inputStr)
?{??
?
if(document.form1.TextBox1.innerHTML.length>1000 )
?{??
?alert("咨詢內容不能超過1000字!");
?var docSel?= document.selection.createRange()
??if (docSel.parentElement().tagName != "INPUT")?return false??
??oSel = docSel.duplicate()
??oSel.text = ""
??var srcRange?= obj.createTextRange()
??oSel.setEndPoint("StartToStart", srcRange)
??var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
??return reg.test(str)
??}
?}
?//輸入方式onpaste時判斷咨詢字符是否超過1000
?function regInputpaste(obj, reg, inputStr)
?{??
?
if(window.clipboardData.getData('text').length+document.form1.TextBox1.innerHTML.length>1000)//粘貼板里的字符長度
?{??
?alert("咨詢內容不能超過1000字!");
?var docSel?= document.selection.createRange()
??if (docSel.parentElement().tagName != "INPUT")?return false??
??oSel = docSel.duplicate()
??oSel.text = ""
??var srcRange?= obj.createTextRange()
??oSel.setEndPoint("StartToStart", srcRange)
??var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
??return reg.test(str)
??}
?}

?
//加載字體進入textarea
function fontin()
{
window.form1.TextBox1.style.cssText=window.form1.TextBox1cssText.value;
}
//url轉超級連接
//$2表示url值
//把=和"替換

function UrlChange(r)??
{
?var re = /(^|[^<=""])(http:(|)(([/w/+/-~`@:%])+/.)+([/w/./=/?/+/-~`@/':!%#]|(&amp;)|&)+)/ig;
?var rewww=/(^|[^/w/=])((www|bbs)/.(/w)+/.([/w/./=/?/+/-~`@/'!%#]|(&amp;))+)/ig;?
?r = r.replace(re, "FORUELSTARTMA$2IMGEND$2FORUELENDMA").replace(rewww, "FORUELSTARTMA$2IMGEND$2FORUELENDMA").replace(//"/g, '&quot;').replace(/=/g, '&#061;');??
?return r;
}
//播放聲音
var Sound = new Object();
Sound.play = function Sound_play(src) {
if (!src) return false;
this.stop();
var elm;
if (typeof document.all != "undefined") {
elm = document.createElement("bgsound");
elm.src = src;
}
else {
elm = document.createElement("object");
elm.setAttribute("data",src);
elm.setAttribute("type","audio/x-wav");
elm.setAttribute("controller","true");
}
document.body.appendChild(elm);
this.elm = elm;
return true;
};

Sound.stop = function Sound_stop() {
if (this.elm) {
this.elm.parentNode.removeChild(this.elm);
this.elm = null;
}
};


</script>?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389280.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389280.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389280.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

溫故而知新:柯里化 與 bind() 的認知

什么是柯里化?科里化是把一個多參數函數轉化為一個嵌套的一元函數的過程。&#xff08;簡單的說就是將函數的參數&#xff0c;變為多次入參&#xff09; const curry (fn, ...args) > fn.length < args.length ? fn(...args) : curry.bind(null, fn, ...args); // 想要…

OPENVAS運行

https://www.jianshu.com/p/382546aaaab5轉載于:https://www.cnblogs.com/diyunpeng/p/9258163.html

Memory-Associated Differential Learning論文及代碼解讀

Memory-Associated Differential Learning論文及代碼解讀 論文來源&#xff1a; 論文PDF&#xff1a; Memory-Associated Differential Learning論文 論文代碼&#xff1a; Memory-Associated Differential Learning代碼 論文解讀&#xff1a; 1.Abstract Conventional…

大數據技術 學習之旅_如何開始您的數據科學之旅?

大數據技術 學習之旅Machine Learning seems to be fascinating to a lot of beginners but they often get lost into the pool of information available across different resources. This is true that we have a lot of different algorithms and steps to learn but star…

純API函數實現串口讀寫。

以最后決定用純API函數實現串口讀寫。 先從網上搜索相關代碼&#xff08;關鍵字&#xff1a;C# API 串口&#xff09;&#xff0c;發現網上相關的資料大約來源于一個版本&#xff0c;那就是所謂的msdn提供的樣例代碼&#xff08;msdn的具體出處&#xff0c;我沒有考證&#xff…

數據可視化工具_數據可視化

數據可視化工具Visualizations are a great way to show the story that data wants to tell. However, not all visualizations are built the same. My rule of thumb is stick to simple, easy to understand, and well labeled graphs. Line graphs, bar charts, and histo…

Android Studio調試時遇見Install Repository and sync project的問題

我們可以看到&#xff0c;報的錯是“Failed to resolve: com.android.support:appcompat-v7:16.”&#xff0c;也就是我們在build.gradle中最后一段中的compile項內容。 AS自動生成的“com.android.support:appcompat-v7:16.”實際上是根據我們的最低版本16來選擇16.x.x及以上編…

Apache Ignite 學習筆記(二): Ignite Java Thin Client

前一篇文章&#xff0c;我們介紹了如何安裝部署Ignite集群&#xff0c;并且嘗試了用REST和SQL客戶端連接集群進行了緩存和數據庫的操作。現在我們就來寫點代碼&#xff0c;用Ignite的Java thin client來連接集群。 在開始介紹具體代碼之前&#xff0c;讓我們先簡單的了解一下Ig…

VGAE(Variational graph auto-encoders)論文及代碼解讀

一&#xff0c;論文來源 論文pdf Variational graph auto-encoders 論文代碼 github代碼 二&#xff0c;論文解讀 理論部分參考&#xff1a; Variational Graph Auto-Encoders&#xff08;VGAE&#xff09;理論參考和源碼解析 VGAE&#xff08;Variational graph auto-en…

IIS7設置

IIS 7.0和IIS 6.0相比改變很大誰都知道&#xff0c;而且在IIS 7.0中用VS2005來調試Web項目也不是什么新鮮的話題&#xff0c;但是我還是第一次運用這個東東&#xff0c;所以在此記下我的一些過程&#xff0c;希望能給更多的后來者帶了一點參考。其實我寫這篇文章時也參考了其他…

tableau大屏bi_Excel,Tableau,Power BI ...您應該使用什么?

tableau大屏biAfter publishing my previous article on data visualization with Power BI, I received quite a few questions about the abilities of Power BI as opposed to those of Tableau or Excel. Data, when used correctly, can turn into digital gold. So what …

python 可視化工具_最佳的python可視化工具

python 可視化工具Disclaimer: I work for Datapane免責聲明&#xff1a;我為Datapane工作 動機 (Motivation) There are amazing articles on data visualization on Medium every day. Although this comes at the cost of information overload, it shouldn’t prevent you …

網絡編程 socket介紹

Socket介紹 Socket是應用層與TCP/IP協議族通信的中間軟件抽象層&#xff0c;它是一組接口。在設計模式中&#xff0c;Socket其實就是一個門面模式&#xff0c;它把復雜的TCP/IP協議族隱藏在Socket接口后面&#xff0c;對用戶來說&#xff0c;一組簡單的接口就是全部。 Socket通…

猿課python 第三天

字典 字典是python中唯一的映射類型,字典對象是可變的&#xff0c;但是字典的鍵是不可變對象&#xff0c;字典中可以使用不同的鍵值字典功能> dict.clear()          -->清空字典 dict.keys()          -->獲取所有key dict.values()      …

在C#中使用代理的方式觸發事件

事件&#xff08;event&#xff09;是一個非常重要的概念&#xff0c;我們的程序時刻都在觸發和接收著各種事件&#xff1a;鼠標點擊事件&#xff0c;鍵盤事件&#xff0c;以及處理操作系統的各種事件。所謂事件就是由某個對象發出的消息。比如用戶按下了某個按鈕&#xff0c;某…

BP神經網絡反向傳播手動推導

BP神經網絡過程&#xff1a; 基本思想 BP算法是一個迭代算法&#xff0c;它的基本思想如下&#xff1a; 將訓練集數據輸入到神經網絡的輸入層&#xff0c;經過隱藏層&#xff0c;最后達到輸出層并輸出結果&#xff0c;這就是前向傳播過程。由于神經網絡的輸出結果與實際結果…

使用python和pandas進行同類群組分析

背景故事 (Backstory) I stumbled upon an interesting task while doing a data exercise for a company. It was about cohort analysis based on user activity data, I got really interested so thought of writing this post.在為公司進行數據練習時&#xff0c;我偶然發…

3.Contructor(構造器)模式—精讀《JavaScript 設計模式》Addy Osmani著

同系列友情鏈接: 1.設計模式之初體驗—精讀《JavaScript 設計模式》Addy Osmani著 2.設計模式的分類—精讀《JavaScript 設計模式》Addy Osmani著 Construct&#xff08;構造器&#xff09;模式 在經典的面向對象編程語言中&#xff0c;Construtor是一種在內存已分配給該對象的…

BZOJ 3653: 談笑風生(離線, 長鏈剖分, 后綴和)

題意 給你一顆有 \(n\) 個點并且以 \(1\) 為根的樹。共有 \(q\) 次詢問&#xff0c;每次詢問兩個參數 \(p, k\) 。詢問有多少對點 \((p, a, b)\) 滿足 \(p,a,b\) 為三個不同的點&#xff0c;\(p, a\) 都為 \(b\) 的祖先&#xff0c;且 \(p\) 到 \(a\) 的距離不能超過 \(k\) 。 …

搜索引擎優化學習原理_如何使用數據科學原理來改善您的搜索引擎優化工作

搜索引擎優化學習原理Search Engine Optimisation (SEO) is the discipline of using knowledge gained around how search engines work to build websites and publish content that can be found on search engines by the right people at the right time.搜索引擎優化(SEO…