Skip to content
Advertisement

Print canvas contents

http://jsfiddle.net/vpetrychuk/LWup5/. As you can see text in the canvas displays ok, but after clicking “Print” button (and saving page as PDF) output image becomes ugly. Any chance to print the canvas contents without blur? Answer You need to make the actual canvas at print size then scale it on screen using CSS rules. The browser will always use the internal

divide number with decimals javascript

how can I divide number (money) to x number equally the number could be with one or two decimal or without it such as 1000 or 100.2 or 112.34 I want to be able to split that number into x part all of them equally, however if it’s not odd number the extra number to the last one. for example

How to read an external local JSON file in JavaScript?

I have saved a JSON file in my local system and created a JavaScript file in order to read the JSON file and print data out. Here is the JSON file: Let’s say this is the path of the JSON file: /Users/Documents/workspace/test.json. Could anyone please help me write a simple piece of code to read the JSON file and print

Moment.js months difference

I’ve been using moment.js for a short while now, and it’s made date manipulation a lot easier but I have a specific case that is failing, and I can’t see why. When calculating the diff between today (31st October 2013) and the 1st February 2014, the months diff comes back as 2, although there are 3 complete months and one

how to create object tree from string in java script

Hi In javascript I have to create object tree from a string as below “group1:node1:properties,group1:node2:properties,group2:node2:properties,group2:node3:properties,group2:node1:properties,group3:node2:properties”. In this, properties are also : seperated, I require object tree as below group1 node1 properties node2 properties group2 node2 properties node3 properties node1 properties group3 node2 properties can any body tell me what is the best way to do that with example. Answer Although

check checkbox and trigger change event javascript

I want to trigger change event and check checkbox from javaScript not jQuery. I am having issues with jQuery because of this Strange Behaviour. What i used to do with jQuery is: I want same to do with javaScript. This must be really simple but i could not find the way . please help thanks in advance Answer There’s a

JavaScript click event listener on class

I’m currently trying to write some JavaScript to get the attribute of the class that has been clicked. I know that to do this the correct way, I should use an event listener. My code is as follows: I was expecting to get an alert box every time I clicked on one of the classes to tell me the attribute

How to create an event handler for a range slider?

I’m trying to get a range slider to work but I can’t. How do I add an event handler so when the user chooses a value my code reads that value. Right now its value is always 1. I would like to do this using pure Javascript. HTML: JAVASCRIPT: JSFIDDLE Answer Single Read The problem is that you’re only reading

socket.io – socket.on wait for promise

I have a button that does some communication with the server to check if an entered value (via an input box) already exists. The code is the following: The problem is that the checkReturn call is asynchronous, and therefore the code carries on without actually waiting for the result. How do I make sure that checkReturn is first finished and

Advertisement