0

选项对象(所谓的)用于从页面收集静态参数以供 javascript 文件操作。将动态值从页面传递到 javascript 选项对象的最佳方法是什么?例如,您应该如何在下面插入 MyAlbumID 的值

MyOptionsObject({
    flashvars: {
        xmlFilePath: "http://myurl.com/images.php?album=" + MyAlbumID
    })​

MyAlbumID 是从哪里获得的:

 var albumspan = document.getElementById("lblMyAlbum");
 var albumtextnode = albumspan.firstChild;
 var MyAlbumID = albumtextnode.data;
4

1 回答 1

0

究竟是什么问题?

onDynamicAction(function(){
    // ensure that the DOM is loaded when that action happens

    var myAlbumID = document.getElementById("lblMyAlbum").firstChild.data;
    // lets hope there is an element with that id and a textnode,
    // so that this threw no error

    MyOptionsObject ({
      flashvars: {
        xmlFilePath: "http://myurl.com/images.php?album=" + myAlbumID
      } // missing bracket, btw.
    });
    // set a new object
})
于 2012-06-07T16:55:16.450 回答