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 = documen开发者_JAVA技巧t.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);
}
var player = null;
function playerReady(thePlayer) {
player = window.document[thePlayer.id];
}
function createPlayer(station) {
//if (player) { }
swfobject.removeSWF('player1');
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);
}
When you remove player1, it removes the streamPlayer div, which isn't added back in when createPlayer runs again.
精彩评论