Frame buster buster

2019-04-13 02:57发布

I'm trying to use a frame-buster-buster, as discussed in this question: Frame Buster Buster ... buster code needed

It works great at stopping the frame buster, unfortunately it also stops any change of the url at all - including clicking links or typing a new address in the address bar.

Is there any way around this? Maybe by clearing the window.onbeforeunload function after the frame has loaded? Or a completely different approach?

1条回答
相关推荐>>
2楼-- · 2019-04-13 03:20

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...

查看更多
登录 后发表回答