0

I am working on an facebook canvas application and want to make the back, forward and refresh browser buttons work with my ajax calls. There are several jquery plugins around that support this action, like jquery.address or history.js.

For IE9 - still HTML4 - I cannot use history pushState or replaceState and therefore need to rely on hash tags. This works well if I own one site completely, but in case we have a situation like in Facebook, where the iFrame is on a different domain than the parent (facebook.com) I am lost - due to the same origin policy.

I am able to set the parent.location.href with the hash change, but am not able to receive events inside the iFrame when the hash changes.

Setting the hash inside the iFrame will not work in IE9 - clicking on the browser back button ignores the hash change I made inside the iFrame.

Anyone sees what I am doing wrong or is inside IE9 just not possible to make use of the browser buttons from inside an iFrame with Ajax calls? Or is there a way to receive the hashchange event from the iFrame parent?

THANKS!

Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247
Marc Loeb
  • 570
  • 9
  • 27

1 Answers1

0

I'd suggest capturing the backspace button, which most people use to go back and to make for IE users only special back buttons, similar to those of ie9, so their instinct will be to use those.

<!--[if lte IE 9]>
   html code for IE users, explaining why they are ignorant... giving them a back button, catching the backspace key and using that....
<![endif]-->
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
  • Smile, I like your answer! So this means no chance to click the browser back/forward/refrsh buttons inside an iFrame... – Marc Loeb Mar 07 '13 at 14:17
  • It still means that they can use the browsers back button. But if you capture the backspace http://stackoverflow.com/questions/2353550/how-to-capture-a-backspace-on-the-onkeydown-event you can use a preventdefault method or returning false, so it doesn't go history.back() but does what you want it to do. And if you provide the user with big back buttons of your own, they'll use that to navigate, hopefully, and you could always use an onunload event handler to warn ie users. – Tschallacka Mar 07 '13 at 14:52
  • Most people use the backspace key to go back? Do you have any data to support that (as it doesn't conform to my expectations)? – Quentin Mar 07 '13 at 14:54
  • everybody I know uses the backspace key because it's too hard to find the back key on the browsers, or they are to lazy to use the trackpad on their notebook. – Tschallacka Mar 07 '13 at 15:24
  • You could use a simple tracking script like this to measure your own statistics. http://jsfiddle.net/xCSbd/ – Tschallacka Mar 07 '13 at 15:36