Chrome并不总是执行javascript document.write代码

时间:2013-05-31 06:38:51

标签: javascript google-chrome

我有以下功能,用于在我的网页上显示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);
}

0 个答案:

没有答案