为什么我不能在此 Javascript 中创建和销毁 swf 对象两次以上
为什么我不能在此 Javascript 中创建和销毁 swf 对象两次以上
有任何线索吗?我会很感激你的建议。
var player = null;
function playerReady(thePlayer) {
player = window.document[thePlayer.id];
}
function createPlayer(station) {
//if (player) { }
swfobject.removeSWF('player1');
if (!player) {
var d = document.createElement("div");
d.setAttribute("id", "streamPlayer");
document.getElementById("content-container").appendChild(d);
}
var flashvars = { file: station, type: "sound", autostart: "true" }
var params = { allowfullscreen: "true", allowscriptaccess: "always" }
var attributes = { id: "player1", name: "player1" }
swfobject.embedSWF("player.swf", "streamPlayer", "320", "20", "9.0.115", false, flashvars, params, attributes);
}
Why can't I create and destroy an swf object more than twice in this Javascript
Any clues? I'll appreciate your advise.
var player = null;
function playerReady(thePlayer) {
player = window.document[thePlayer.id];
}
function createPlayer(station) {
//if (player) { }
swfobject.removeSWF('player1');
if (!player) {
var d = document.createElement("div");
d.setAttribute("id", "streamPlayer");
document.getElementById("content-container").appendChild(d);
}
var flashvars = { file: station, type: "sound", autostart: "true" }
var params = { allowfullscreen: "true", allowscriptaccess: "always" }
var attributes = { id: "player1", name: "player1" }
swfobject.embedSWF("player.swf", "streamPlayer", "320", "20", "9.0.115", false, flashvars, params, attributes);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您删除player1时,它会删除streamPlayer div,当createPlayer再次运行时它不会被添加回来。
When you remove player1, it removes the streamPlayer div, which isn't added back in when createPlayer runs again.