To send something to all clients, you use: To receive from clients, you use: How can I combine the two so that when recieving a message on the server from a client, I send that message to all users except the one sending the message? Do I have to hack it around by sending the client-id with the message and
Tag: javascript
Javascript onbeforeunload to open window.open() popup
I am trying to write a onbeforeunload event that triggers a window.open(url) etc. I want it to be triggered if the user trys to leave the page or if they close their browser, but not when they click any of the buttons on the page. The buttons on the page post data to the same page via a javascript. javascript…
How does a JavaScript parser work?
I’m trying to understand how JS is actually parsed. But my searches either return some ones very vaguely documented project of a “parser/generator” (i don’t even know what that means), or how to parse JS using a JS Engine using the magical “parse” method. I don’t want…
Remove Object from Array using JavaScript
How can I remove an object from an array? I wish to remove the object that includes name Kristian from someArray. For example: I want to achieve: Answer You can use several methods to remove item(s) from an Array: If you want to remove element at position x, use: Or Reply to the comment of @chill182: you can …
Resizing ‘iframe’ after inside content is loaded
I have an iFrame in which I am loading a page which uses ajax to load data after various page labels are clicked. Now I am using Javascript function to calculate loaded-data height for replacing iframe’s height which results into resizing iframe and thus avoids scrollbars. Now my problem is script gets …
HTML5, canvas, and strokeRect: some lines too narrow and blurry
A stupid simple canvas usage: Yields a rectangle with narrower lines along top and left: Why does this happen? Do I need to offset with padding? It’s annoying. Answer 2 things. First, odd lineWidths (1, 3, 5, …) will never apply cleanly with drawn on integer pixel values. This is because X and Y r…
Check if innerHTML is empty
I have a ajax call on my onkeyup event, that checks if the given email address is in the database or not. My problem is, that I can’t find a right solution to check if the ajax response is EMPTY and if yes I need to disable a button. This is the ajax.php output: This is the JavaScript for the
Ajax call Into MVC Controller- URL Issue
I’ve looked at the previously-posted jQuery/MVC questions and haven’t found a workable answer. I have the following JavaScript code: When calling the Url the post looks like: Why does it return it like this (the logic behind it) and what’s a solution? P.S.: Additional Information: %22 is the…
add .js file as source in html file from server
I have an HTML file on my server, and a Javascript file on the same server. I want it so that when I load the HTML file, it will the reference of .js file placed on the server. I tried this way: but it is not working. Can any one tell me how I can do this?! I attached the
JavaScript get word before cursor
Okay, I’ve been looking all over the web to find a solution but I couldn’t find one, is there a way to get the word before the caret position in an editable div so a bit like: This should return the word “some”… I don’t know if this is possible, I would be glad for any help…