PDA

View Full Version : JS Simple script only works in Safari



BenBart
May 10th, 2010, 05:52 PM
This script only seems to be working in Safari, but I would like it to run in safari and firefox. Any clue why it doesn't work in firefox?

Thank you for your time.


function init()
{
var myCanvas = window; //Using "window" for testing
myCanvas.addEventListener("mousedown", traceEventType);

}

window.onload = init;

function traceEventType(e)
{
alert(e.type);
}

mrE
May 11th, 2010, 11:44 AM
You may be surprised to find that the solution is rather simple.

on line 4 - after you call traceEventType, insert another argument value of "false"

in other words, use this:

myCanvas.addEventListener("mousedown", traceEventType, false);