be friendly also to Node environments and use alert() only if existing and fallback to console.log