引:http://stackoverflow.com/a/18453540
引用
This appears to be an IE9-only bug.
It occurs when a Flash object interacts with a HTML document using JavaScript (ExternalInterface on the Flash/ActionScript-side) and rears it's ugly head when an IFRAME containing the HTML document w/ the Flash Object comes into play.
Seeing how you specify you're using the YouTube API, there is sadly nothing you can do to make sure the Flash unregisters itself and won't call JavaScript functions (or vice versa) when it's time to remove it as you rely on third party software running outside your applications domain.
If you don't NEED the YouTube API, but merely a quick way to get a video within your application, the safest bet is to use an old style object embed for IE9 and the API / IFRAME embedding for the rest of the sane world.
<object width="{WIDTH}" height="{HEIGHT}">
<embed src="https://www.youtube.com/v/{VIDEO_ID}?version=3&autoplay=1"
type="application/x-shockwave-flash"
allowscriptaccess="always"
width="{WIDTH}" height="{HEIGHT}"></embed>
</object>
Removing above object (you can use SWFObject's "embedSWF" and "removeSWF" just fine for this btw) will get the video player off your page, without throwing any _flash_remove.. warnings.
If you NEED the YouTube API / control over the video player state:
Have you tried invoking the "destroy"-method on the ytplayer ? Unvoke the destroy and while I'm reluctant to posting "answers" using timeouts, give the Flash object some time to unregister BEFORE your set the source of the iframe to an empty string (so the document unloads), then clear the iframe or it's parent container.
Though I remember from a previous project this drove us mad (the context being a single-page interface where videos were dynamically added and removed) and we resorted to writing our own Flash player fallback using the AS3 YT code. That's how annoying it got.
解决办法,在 iframe 页面中加入如下代码:
// 解决 IE9 下, iframe 中flash不能正常销毁的问题
// see http://stackoverflow.com/a/18453540
$(window).unload(function() {
if (null != swfplayer) {
try {
swfplayer.stop2();
}catch(e){}
}
$("#player").remove();
$(window).remove();
});
分享到:
相关推荐
Iframe内存泄露分析,Iframe内存泄露分析
建立flex project后import压缩包中的文件即可
flex iframe 支持在flash中嵌套入html jsp asp php等flex iframe 支持在flash中嵌套入html jsp asp php等flex iframe 支持在flash中嵌套入html jsp asp php等flex iframe 支持在flash中嵌套入html jsp asp php等flex...
主要介绍了使用iframe在网页中嵌入其他网页的方法,需要的朋友可以参考下
iframe嵌入网页的一部分, 拿别人网页为你所用
js控制/获取a.html中iframe加载的b.html中的iframe,很多人都以为getElementById可以直接获取,其实不行的,以上代码就解决了这个问题,js控制iframe加载页面的iframe,不过测试只在IE和火狐通过,谷歌不行,其他自...
主要介绍了IE下使用jQuery重置iframe地址时内存泄露问题解决办法,需要的朋友可以参考下
Flex中利用IFrame解决嵌入HTML时Flex组件被遮挡和IFrame被隐藏的问题,包括Flex菜单、弹出界面、右键菜单等功能,本例中只提供解决对Flex 菜单的遮挡问题解决
让嵌入到HTML的iframe自动适应大小
iframe嵌入链接本地环境正常,正式环境重定向到登录解决iframe嵌入链接本地环境正常,正式环境重定向到登录解决iframe嵌入链接本地环境正常,正式环境重定向到登录解决iframe嵌入链接本地环境正常,正式环境重定向到...
最近做的合作网站嵌入到对方的iframe中去,在safari,opera和有些版本的搜狗浏览器(内核版本原因)中不能读到cookie。
这是关于iframe使用过程中出现的问题整理的解决方法,关于使用iframe不用单独写接口打通数据,直接把数据通过ifarme嵌套方法传递过去,使用简单方便。
IFrame对象占用的内存资源在窗体关闭后不会释放。弹出关闭反复多次后,IE浏览器内存占用可超过数百M,严重时IE浏览器报错
IFrame中Session丢失的解决办法
根据项目中的实际情况,总结的Flex嵌入IFrame解决方案
js调用-嵌入iframe,测试JS之间的调用关系
iframe内容页白块及刷新白色背景问题解决,在IE6,IE9上测试通过。
框架完美解决了iframe之间的跨域通讯。底层技术采用window.name转换代理实现
解决下拉菜单被iframe遮住问题吗,
HTML中使用iframe嵌入其他界面,增加页面的灵活性、可嵌入性