我有以下功能,用于在我的网页上显示 adobe flash swf。从现在开始大约一周后,我们发现这段代码并不总是在 chrome 上执行。
即使该函数在单个页面上被调用 2 次,有时它也只执行一次。当页面被刷新时,函数执行没有任何问题。我在整个站点中都使用相同的函数,函数调用的编写方式完全相同。
并且该函数不会在每次调用时都被执行。
我认为这个错误可能来自 document.write 代码,但我不确定,谁能帮我解决这个问题。
亲切的问候 V!nay
function writeSWFCode(movie,var_string , movie_name, width, height, bgcolor,flash_align,flash_menu,flash_scale,flash_wmode,flash_version,flash_hspace,flash_vspace){
//check for domain name... if none, use flash
var HasProtocol=movie.indexOf('http://');
if(HasProtocol==-1){
movie=UpToTenFlashDomain + movie;
}
// alert (movie);
if(bgcolor == '' || bgcolor == undefined){
//Default color is white... WHen the BG color to a movie is a color, the Background to any print job will be that color too !
bgcolor = '#FFFFFF';
}
if(flash_version == '' || flash_version == undefined){
flash_version = '6,0,29,0';
}
if(flash_align == '' || flash_align == undefined){
flash_align = 'middle';
}
if(flash_menu == '' || flash_menu == undefined){
flash_menu = 'false';
}
if(flash_hspace == '' || flash_hspace == undefined){
flash_hspace = '0';
}
if(flash_vspace == '' || flash_vspace == undefined){
flash_vspace = '0';
}
if(flash_wmode == '' || flash_wmode == undefined){
flash_wmode_object='';
flash_wmode_embed='';
}else{
flash_wmode_object='<PARAM NAME="wmode" VALUE="'+flash_wmode+'">';
flash_wmode_embed=' wmode="'+flash_wmode+'" ';
}
if(flash_scale == '' || flash_scale == undefined){
flash_scale='exactfit';
}
var browserName =navigator.appName;
var flash_code ='';
flash_code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" align="'+flash_align+'" id="'+movie_name+'"><param name="movie" value="'+movie+'" /><param name="quality" value="high" /><param name="bgcolor" value="'+bgcolor+'" /><param name="play" value="true" /><param name="loop" value="true" />'+flash_wmode_object+'<param name="scale" value="'+flash_scale+'" /><param name="menu" value="'+flash_menu+'" /><param name="devicefont" value="false" /><param name="salign" value="" /><param name="allowScriptAccess" value="always" /><param name="FlashVars" value="'+ var_string +'" />';
if (browserName!="Microsoft Internet Explorer")
{
flash_code = flash_code + '<object data="'+movie+'" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" align="'+flash_align+'"><param name="movie" value="'+movie+'" /><param name="quality" value="high" /><param name="bgcolor" value="'+bgcolor+'" /><param name="play" value="true" /><param name="loop" value="true" />'+flash_wmode_object+'<param name="scale" value="'+flash_scale+'" /><param name="menu" value="'+flash_menu+'" /><param name="devicefont" value="false" /><param name="salign" value="" /><param name="allowScriptAccess" value="always" /><param name="FlashVars" value="'+ var_string +'" />';
}
flash_code = flash_code + '<a href="http://www.adobe.com/go/getflash"><img src="xxx" alt="Get Adobe Flash player" /></a>';
if (browserName!="Microsoft Internet Explorer")
{
flash_code = flash_code +'</object>';
}
flash_code = flash_code +'</object>';
document.write(flash_code);
// alert(flash_code);
}