Fix javascript error occuring when e is null/undefined

An error was coming up in console every time you switched tabs.