以下代码在同一个div中一次一个地加载3个swf文件。 如何在PHP或javascript中跟踪特定时间的SWF加载我想在某些地方使用IF语句,如if($ i == 1)其中$ i是1.swf加载时的变量等于1当2.swf加载时,$ i == 2。
function loadFlash(){
function getRandomFilename()
{
var names = [
'1.swf',
'2.swf',
'3.swf'
];
var r = Math.floor(Math.random() * names.length);
return names[r];
}
var flashvars = {};
var params = {wmode:"opaque"};
var attributes = {};
swfobject.embedSWF(getRandomFilename(), "SWF_Output", "900", "120", "8.0.0", false, flashvars, params, attributes);
}
Mob ...提前致谢
答案 0 :(得分:0)
像这样编辑你的代码:
function loadFlash(){
function getRandomFilename() {
var names = [
'1.swf',
'2.swf',
'3.swf'
];
var r = Math.floor(Math.random() * names.length);
return [names[r], r];
}
var flashvars = {};
var params = {wmode:"opaque"};
var attributes = {};
var file = getRandomFilename();
swfobject.embedSWF(file[0], "SWF_Output", "900", "120", "8.0.0", false, flashvars, params, attributes);
//file[0] will be the file name ('1.swf' - '3.swf')
//file[1] will be the array index (0 - 2)
}
您无法在names[r]
函数(out of scope)之外访问getRandomFilename