HTML5 Canvas – Nice flame/fire effect using particles

Try following HTML script. Shows nice flaming/fire effect using Javascript and CSS.

Javscript:
window.onload = function(){
var canvas = document.getElementById(“canvas”);
var ctx = canvas.getContext(“2d”);

//Make the canvas occupy the full page
var W = window.innerWidth, H = window.innerHeight;
canvas.width = W;
canvas.height = H;

var particles = [];
var mouse = {};

//Lets create some particles now
var particle_count = 100;
for(var i = 0; i < particle_count; i++)
{
particles.push(new particle());
}

//finally some mouse tracking
canvas.addEventListener(‘mousemove’, track_mouse, false);

Continue reading

How to call a javascript function after pressing enter key in input box

If you got the errors in IE browsers after calling some Javascript
functions on input box event, then user the following methodology
to get rid of it:

<input type="text" id="txtSearch" 
onkeydown="if (event.keyCode ==13) document.getElementById('btnSearch').click()"/>

<input type="button" id="btnSearch" value="Search"
onclick="doSomething();" />