How do I get flash to reload the parent HTML page it is embedded in?

一个人想着一个人 提交于 2019-12-07 07:25:09

问题


I have a flash app (SWF) running Flash 8 embedded in an HTML page. How do I get flash to reload the parent HTML page it is embedded in? I've tried using ExternalInterface to call a JavaScript function to reload the page but that doesn't seem to work. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­


回答1:


Check the ExternalInterface in Action Script. Using this you can call any JavaScript function in your code:

  if (ExternalInterface.available)
  {
    var result = ExternalInterface.call("reload");
  }

In the Embedding HTML code enter a JavaScript function:

  function reload()
  {
    document.location.reload(true);
    return true;
  }

This has the advantage that you can also check, if the function call succeeded and act accordingly. getUrl along with a call to JavaScript should not be used today anymore. It's an old hack.




回答2:


Try something like this:

getURL("javascript:location.reload(true)");




回答3:


Simple one line solution.

ExternalInterface.call("document.location.reload", true);



回答4:


Quick and dirty: This will work in most cases (without modifying the HTML page at all):

import flash.external.ExternalInterface;

ExternalInterface.call("history.go", 0);



回答5:


In Flash 10 you can do:

navigateToURL(new URLRequest("path_to_page"), "_self");


来源:https://stackoverflow.com/questions/96671/how-do-i-get-flash-to-reload-the-parent-html-page-it-is-embedded-in

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