views:

88

answers:

1

Yahoo mail is now injecting disgusting amounts of code including css and javascript into html emails.

I've found a way to over ride some of their css by writing styles using their class of .yshortcuts.

Now, I was wondering if there is a javascript call which would say "Stop all javascript functionality after this call"

I know, pretty awesome and advanced if possible but I just wanted to see if there was a way. Almost like a self-kill switch that others have.

A: 

Really the only way to stop Javascript execution is to trigger a Javascript error -- which means deliberately introducing a bug in your code, which isn't really a great idea. But realize that if you do that, all Javascript functionality on the page could stop executing (so that means event handlers, AJAX polling, etc.), depending on syntax and what browser you're using (see the comments for an example).

Daniel Vandersluis
ahh... nice idea. These are simple html emails... I'll have to see whether the tracking is installed in these or not. Thanks
Billy
This won't work in Firefox though. I don't know by what rules it continues execution after an error, but it does.
Pekka
Even then, it'll only break at the point of introducing the error. I assume Yahoo is smart enough to not allow other's JS to execute before theirs. Actually, I hope Yahoo is smart enough to not even allow .js to be executed at all in emails.
DA
@Pekka it really depends on the Javascript. I wrote up a simple test at http://jsfiddle.net/erv3T/2/ -- In Firefox, the in-script `alert` never fires, and the first button which has an event added through `addEventListener` doesn't fire either (even though it was defined before the syntax error), but the second button with an `onclick` attribute does.
Daniel Vandersluis
Does not work, an error only stops execution on that "thread (context of execution)". A separate script tag uses a different thread. Event handlers that were already installed also will run (in the separate event thread)
Juan Mendes