使用YouTube API的IE8中出现“预期对象”错误

问题描述

| IE8中出现了一些问题,其中包含一些使用Data API来显示YouTube视频的JavaScript。 我收到的错误是\'Object Expected \',这是第二行代码引起的。
// <![CDATA[
var baseUrl = \'http://www.youtube.com/\';
var swfUrl = constructUrl(baseUrl);

// allowScriptAccess must be set to allow the Javascript from one
// domain to access the swf on the youtube domain
var params = { allowScriptAccess: \"always\",bgcolor: \"#cccccc\" };

// This sets the ID of the DOM object or embed tag to \'myytplayer\'.
// You can use this ID to access the swf and call the player\'s API
var atts = { id: \"myytplayer\" };
var flashvars = {};
swfobject.embedSWF(swfUrl,\"ytapiplayer\",\"220\",\"125\",\"9\",null,flashvars,params,atts);
//]]>
有没有人遇到此错误,您是否有经过测试的解决方案?     

解决方法

        IE会在很多情况下吐出“期望的对象”错误,包括未定义的函数。在此函数的上下文中,很可能没有包含定义
constructURL()
的库。