我正在开发一个网站,其主要部分由 ajax 风格的导航系统驱动,使用 url 中的锚点来定义应用程序状态。
除此之外,我现在需要支持在此应用程序之上加载的 IFrame。我遇到的问题是,如果我使用片段,后退按钮就会损坏。
我创建了一个非常简单的示例,它没有使用任何ajax图书馆。它所拥有的只是一个向 url 添加锚点的链接和一个 iframe,其中包含一些普通链接。
如果我先单击锚链接,然后单击 iframe 中的链接,我希望第一次返回单击返回到原始 iframe 页面,第二次单击从 url 中删除锚。
我知道那里有所有各种解决方案(YUI,真正简单的历史,jquery 插件),它们都工作得很好,但它们不适合 iframe。
我还知道我可以向框架页面添加一些 JS,并可能通过父页面路由所有导航,但我希望这不是必需的。
所以问题是,任何人都可以解释一下这个 示例?其次,我可以从父 iframe 中做些什么来诱导历史对象拾取这些导航条目吗?
注意:我在此示例中仅询问有关 FF/Safari/Chrome 的信息。 IE需要单独看。
I am working on a site where the main part of it is driven by an ajax style navigation system using anchors in the url to define the application state.
On top of this I now need to support IFrames that are loaded on top of this application. The problem I'm having is that the back button breaks if I make use of fragments.
I've created a very simple sample, that isn't using any of the ajax libraries. All it has is a link that adds an anchor to the url and an iframe, with some normal links in it.
If I click then anchor link first, then I click the link in the iframe, I would expect the first back click to take back to the original iframe page and the second click to remove the anchor from the url.
I'm aware of all the various solutions out there (YUI, reallysimplehistory, jquery plugin) and they all work great, but they don't cater for iframes.
I'm also aware that I could add some JS to the framed pages and possibly route all navigation through the parent page, but I'm hoping that isn't necessary.
So the question is, can anyone explain what is going on inside the history object in this sample? Secondly is there anything I can do from the parent iframe to coax the history object to pick up these navigation entries?
Note: I'm only enquiring about FF/Safari/Chrome in this sample. IE needs to looked at separately.
发布评论
评论(1)
参考
JavaScript .hashchange 性能。它会带来任何放缓吗?
和
Gmail 如何在富 JavaScript 中处理后退/前进?
Refer to
JavaScript .hashchange performance. Can it bring any slowdown?
and
How does Gmail handle back/forward in rich JavaScript?