Misunderstood javascript events, trying events on document object