views:

492

answers:

2

I'm trying to use a frame-buster-buster, as discussed in this question: http://stackoverflow.com/questions/958997/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?

A: 

If Myspace has placed a restriction on content, I'd presume they won't like it if you "work around" a limitation you've encountered. Can you be absolutely sure that the restrictions to the URL bar are unintended?

David Toso
I should be able to display my Myspace page in any way I want.Until Myspace provide an external API, a frame is the best I can do.
zaius
A: 

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

zaius