为什么我不能在此 Javascript 中创建和销毁 swf 对象两次以上

发布于 2024-10-10 17:46:38 字数 774 浏览 3 评论 0原文

为什么我不能在此 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤独岁月 2024-10-17 17:46:38
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);
  }

当您删除player1时,它会删除streamPlayer div,当createPlayer再次运行时它不会被添加回来。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文