How to make the browser back button work for a Flash-based Website?

我们两清 提交于 2019-12-24 21:50:57

问题


Is it possible to make the flash content go back to some previous frame when the user clicks on the back button in the browser? Similarly, can the the refresh button be used to refresh to the same frame and not go back to the starting frame?


回答1:


It depends on how you build it. First of all, you need to import something called SWFAddress. In order to use SWFAddress you need to make sure you're embedding your Flash using SWFObject, not just object/embed tags.

SWFAddress lets you append anchor tags to your url. What this allows you to do is change the URL in a way that the browser can understand without forcing a refresh of the page.

So for instance, if my app is at www.mypage.com/flash.html and I install SWFAddress I can set it up so that when I press a button to go to page 2 the following happens:

  1. SWFAddress changes my URL to www.mypage.com/flash.html#page2
  2. The JavaScript SWFAddress files notice this change and inform Flash.
  3. Flash says "Oh look there's been a URL change and someone is passing me the value "page2" - what should I do with that?
  4. You can set up a switch statement that will allow flash to respond to these events in intelligent, predictable ways - for instance, you can say "if the url changes to 'page2' then gotoAndStop(2)" if that's how you're running things.

I wouldn't necessarily be doing it with Frames, though - what you really want are functions to control the way Flash behaves. So instead of sticking all of your page two content into frame 2, you'd create function gotoPage(2) and put your logic there.

As far as refreshing a frame, again that's going to depend on how you code it - but if someone hits refresh in the browser it will always refresh the browser window. With SWFAddress, though, if you have it set up right it will always take them to the destination that you've linked to the anchor tag.

Does that help? Any questions?




回答2:


Try using SWFAddress. Here is simple demo. Lee has a nice video tutorial to get you started.




回答3:


The browser buttons work on web file documents, like html, htm, php, cfm, jsp, etc. When your browser a flash page, your remaining on the same, and the content changes based on how it is programmed and how the user is interacting with the document. So no, those buttons don't work as you'd like to for a flash document.



来源:https://stackoverflow.com/questions/1828396/how-to-make-the-browser-back-button-work-for-a-flash-based-website

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!