How can I remove a swf file that's embedded in html using a button in the swf?

懵懂的女人 提交于 2019-12-13 02:57:46

问题


I have a swf file that's embedded in a html page, and I have a close button in the swf page, I want the swf to disappear when I click on the button, what is the best way to do that? Thanks.


回答1:


If your ursing swfobject 2.1 to embed the swf you can use this built-in javascript swfobject.removeSWF() function:

function removeFlashFromHTML() 
{
 swfobject.removeSWF("id_of_your_html_object");
}

now you call the javascript function from flash using ExternalInterface:

function buttonClicked(evt:MouseEvent) 
{
 if (ExternalInterface.available) {
  ExternalInterface.call("removeFlashFromHTML()");
 }
}

for more information about SWFObject check this website




回答2:


Write a JavaScript function that will hide the swf or its containing element, and call that function via the "close button" in the swf itself.




回答3:


Heres an article on how to get flash to call some JS on your page. If you never want it back (after hiding) i suggest you remove it from the DOM to release resources, as flash is expensive in client environments.



来源:https://stackoverflow.com/questions/288445/how-can-i-remove-a-swf-file-thats-embedded-in-html-using-a-button-in-the-swf

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