Skip to content
Advertisement

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 refer to the space between pixels

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 URL Encoding Reference for <<“>> character Answer In order for this to

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, thanks :). Answer

Convert Python None to JavaScript null

In a Django view I am generating a data set something like this: I am passing this data to a JavaScript variable using: For use in a High Charts script. Unfortunately JavaScript is stumbling when it encounters the None value because actually what I need is null. How can I best replace None with null, and where should I handle

How do I convert an integer to binary in JavaScript?

I’d like to see integers, positive or negative, in binary. Rather like this question, but for JavaScript. Answer A solution i’d go with that’s fine for 32-bits, is the code the end of this answer, which is from developer.mozilla.org(MDN), but with some lines added for A)formatting and B)checking that the number is in range. Some suggested x.toString(2) which doesn’t work

Connect between different row of table

I have a table with 100 or more rows that are created at runtime in asp.net by Table. This table shows projects of a user. Different user have some different projects. I want when admin clicks on row of name user show rows content list of user project (slideToggle). Answer Take look to this: http://jqueryui.com/demos/accordion/ I think this is what

Remove objects on disconnect socket.io

I’m using Nodejs and Socket.io. When the client connects, new JavaScript objects are created. Do these objects just linger forever? Should they be deleted or removed when the client disconnects? Is it even possible to remove an object? I know delete won’t work… Thanks – I guess this is more of a general question and any suggestions would be really

What is this JavaScript “require”?

I’m trying to get JavaScript to read/write to a PostgreSQL database. I found this project on GitHub. I was able to get the following sample code to run in Node. Next I tried to make it run on a webpage, but nothing seemed to happen. I checked on the JavaScript console and it just says “require not defined”. So what

Advertisement