View WebSocket connection information in Chrome browser

Source: Internet
Author: User

1. The following code implements a WebSocket connection, enter content in the text input box, click Send, go through the server, return the same content displayed below.

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>WebSocket</title>6 </Head>7 <Body>8     <H1>Echo Test</H1>9     <inputtype= "text"ID= "Sendtxt">Ten     <ButtonID= "Sendbtn">Send</Button> One     <DivID= "Recv"></Div> A     <Scripttype= "Text/javascript"> -         varWebSocket= NewWebSocket ("ws://echo.websocket.org/"); - Websocket.onopen= function(){ the Console.log ("WebSocket Open"); - document.getElementById ("recv"). InnerHTML= "Connected"; -         } - Websocket.inclose= function(){ + Console.log ('WebSocket Close'); -         } + Websocket.onmessage= function(e) { A Console.log (e.data); at document.getElementById ("recv"). InnerHTML=E.data; -         } - document.getElementById ("sendbtn"). onclick= function(){ -             vartxt=document.getElementById ("Sendtxt"). Value; - websocket.send (TXT); -         } in  -     </Script> to </Body> + </HTML>

See the information below via the Chrom Browser developer tool:

(1) Click Network, select the WS bar, and select Filter.

(2) Refresh the page to see a WS connection.

(3) Click.

(4) You can also view the information entered and sent.

View WebSocket connection information in Chrome browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.