我使用下面的函数来创建用于显示 Flash 对象的代码。原始闪存大小为 320x240,但我想将其显示为 200x150,因此我使用参数宽度为 200,高度为 150 的函数。所有浏览器都可以正常工作,但 chrome 不能。它显示为 200x151(检查代码显示为 200x151 大小)。为什么?
function getFlashCode(params)
{
debug('getFlashCode');
var defaultParams = {movie: '', flashvars: {}, width:'', height: ''};
for (var key in defaultParams)
{
if (params[key] === undefined)
params[key] = defaultParams[key];
}
var flashvars = '';
for (var key in params.flashvars)
flashvars += encodeURIComponent(key) + '=' + encodeURIComponent(params.flashvars[key]) + '&';
var id = "fl" + Math.random();
var code="";
code += " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + params.width + "\" height=\"" + params.height + "\" align=\"middle\" id=\"" + id + "\">";
code += " <param name=\"movie\" value=\"" + params.movie + "\" \/>";
code += " <param name=\"quality\" value=\"high\" \/>";
code += " <param name=\"play\" value=\"true\" \/>";
code += " <param name=\"loop\" value=\"true\" \/>";
code += " <param name=\"wmode\" value=\"transparent\" \/>";
code += " <param name=\"scale\" value=\"showall\" \/>";
code += " <param name=\"menu\" value=\"true\" \/>";
code += " <param name=\"devicefont\" value=\"false\" \/>";
code += " <param name=\"salign\" value=\"\" \/>";
code += " <param name=\"allowScriptAccess\" value=\"always\" \/>";
code += " <param name=\"flashvars\" value=\"" + flashvars + "\" \/>";
code += " <!--[if !IE]>-->";
code += " <object type=\"application\/x-shockwave-flash\" flashvars=\""+ flashvars + "\" data=\"" + params.movie + "\" width=\"" + params.width + "\" height=\"" + params.height + "\">";
code += " <param name=\"movie\" value=\"" + params.movie + "\" \/>";
code += " <param name=\"quality\" value=\"high\" \/>";
code += " <param name=\"play\" value=\"true\" \/>";
code += " <param name=\"loop\" value=\"true\" \/>";
code += " <param name=\"wmode\" value=\"transparent\" \/>";
code += " <param name=\"scale\" value=\"showall\" \/>";
code += " <param name=\"menu\" value=\"true\" \/>";
code += " <param name=\"devicefont\" value=\"false\" \/>";
code += " <param name=\"salign\" value=\"\" \/>";
code += " <param name=\"allowScriptAccess\" value=\"always\" \/>";
code += " <param name=\"flashvars\" value=\"" + flashvars + "\" \/>";
code += " <\/object>";
code += " <!--<![endif]-->";
code += " <\/object>";
return code;
}