A simple webim has been developed in previous articles, but this webim is on an independent page. Today, webim is a version that can be embedded in its own webpage, you only need to add a fewCodeYou can embed a webim in the page. However, the webim function is simple at present. If you have any requirements, you can submit them in the comments or contact me through webim. In the future, online applications such as online network disks on the Yunxiang online software platform may be integrated.
Source code download
DownloadSource codeTo embed webim into the web page, follow these steps.
1. Copy the bin, app_data, and Yunxiang folders in release to the root directory of the website.
2. Add a reference on the page to be embedded in webim:
< Link Href = "Yunxiang/themes/default/skin.css" REL = "Stylesheet" Type = "Text/CSS"/> < Script SRC = "Yunxiang/json2.js" Type = "Text/JavaScript"> </ Script > < Script SRC = "Yunxiang/config. js" Type = "Text/JavaScript"> </ Script > < Script SRC = "Yunxiang/CORE. js" Type = "Text/JavaScript"> </ Script >
3. Add the following code to application_start and application_end of Global. asax (if global. asax is not available, copy global. asax to the root directory of the website)
VoidApplication_start (ObjectSender,EventargsE ){// In ApplicationProgramCode that runs at startupYunxiang.Messagemanagement. Instance. initialize (context );}VoidApplication_end (ObjectSender,EventargsE ){// Code that runs when the application is closedYunxiang.Messagemanagement. Instance. Dispose ();}
4. Add the following configuration to the httphandlers node of Web. config:
< Httphandlers > < Add Path = " Lesktop. aspx " Verb = " * " Type = " Yunxiang. lesktop " /> < Add Path = " Recevie. aspx " Verb = " * " Type = " Yunxiang. webim_receivehandler " /> < Add Path = " Send. aspx " Verb = " * " Type = " Yunxiang. webim_sendhandler " /> </ Httphandlers >
5. After webim is embedded into the page, you can start the session in the following two ways:
System. startchat ("User Name","Peer user name");
// If the user is not specified, it is entered at startup.System. startchat ();
6. FAQs
(1) Does embedding webim affect the page startup speed?
Because the core. js file must be referenced to embed webim, You need to download several more files after embedding webim. However, as long as the session is not started, the webim-related script (window. JS, controls. JS, desktop. JS, webim. (JS). It is loaded only when it is started for the first time.
(2) will webim insert DOM objects?
Webim does not insert any DOM object as long as the session is not started.