From the course: Learning SignalR with ASP.NET Core

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Build the JavaScript client

Build the JavaScript client

From the course: Learning SignalR with ASP.NET Core

Start my 1-month free trial

Build the JavaScript client

- [Instructor] Let's build a chat box using the HTML. And then use the JavaScript SignalR client to connect it to our hub. If you take a look at the index page, there are some hidden DOM elements here that represent a chat dialogue that will pop up when someone visits the page. If you're following along, you can open up this project from the exercise files, to get this code. I wanna make this dialogue pop up when the page loads. I'll do that in wwwroot, js, index.js. There's already some code in here from the exercise files. What I want to do is add a new function called showChatDialog. This is simply going to grab element from the DOM, dialogEl, document.getElementById. ChatDialog is the ID. And then I wanna do dialogEl.style, then set the display to block. Now I'll write a function called ready, which fires when the page loads. And this will set a timeout, so that this pops up after about a second. setTimeout for showChatDialog, say, 750 milliseconds after the page is ready. And, at…

Contents