There is nothing wrong with your code. When I tried in a Firefox build and ran the same lines, I didn't receive that error. My guess is that this error is being caused by something else in your browser like the extension that the StackOverflow thread discusses.
Here is what my code looks like:
location.href = "mailto:" + "firstname.lastname@example.org"
"mailto:email@example.com" // what gets called. My mail app launches.
That's a good thing, for
location.href is really useful. There isn't any alternative to it on the table haha.