This is what I ended up going with. It ignores only the next redirect after the page has loaded. The major downside of this method is that if the frame never calls its framebuster (e.g. because it doesn't load properly, or the framed site changes their code), this will stop the next attempted page movement. A possible solution would be to execute it after frame page load, but directly before any script executes. Another solution would be to only catch url changes to the framed host's base URL. I have no idea if that's possible though...
function ignore_next_redirect() {
var redirect_timer;
var prevent_bust = 0
window.onbeforeunload = function() { prevent_bust++; }
redirect_timer = setInterval(function() {
if (prevent_bust > 0) {
window.top.location = 'http://example.org/204'
window.onbeforeunload = function() {}
clearInterval(redirect_timer);
}
}, 1);
}
It still does have problems - it seems to stop loading content if it happens at the start of the page.
I know a solution is out there somewhere - google images seem to have got it working. Will update with any progress...