2010-06-06 51 views
0

我需要修复哪些代码?谢谢!无法对此代码进行document.write

document.write(' 
      var parameters = 
       { id: "1" 
       , src: "<?php echo $source?>" 
       , autoPlay: "false" 
       , width: "638" 
       , height: "400" 
       , autoHideControlBar: "false" 
       , controlBarPosition: "bottom" 
       }; 

      swfobject.embedSWF 
       ("vcp.swf" 
       , "player" 
       , parameters["width"], parameters["height"] 
       , "10" 
       , {} 
       , parameters 
       , { allowFullScreen: "true" } 
       , { name: "sMPlayback" } 
       ); 
'); 
+2

欢迎来到SO。你有什么问题?什么不行?请添加更多的附件并描述你正在做的事情。 – 2010-06-06 14:53:00

+0

这是在外部文件还是在页面中,如果它在页面中,为什么即使使用'document.write'? – 2010-06-06 14:53:37

+0

在与HTML相同的页面中,由于双引号或分号错误,我发现这个Javascript代码没有执行? – proyb2 2010-06-06 14:55:02

回答

3

你不能有字符串中的新线,如你有,你传递给document.write()字符串有他们......但因为你的页面的时候,只是删除了document.write,所以你的结果应该是这样的:

<script type="text/javascript"> 
     var parameters = 
      { id: "1" 
      , src: "<?php echo $source?>" 
      , autoPlay: "false" 
      , width: "638" 
      , height: "400" 
      , autoHideControlBar: "false" 
      , controlBarPosition: "bottom" 
      }; 

     swfobject.embedSWF 
      ("vcp.swf" 
      , "player" 
      , parameters["width"], parameters["height"] 
      , "10" 
      , {} 
      , parameters 
      , { allowFullScreen: "true" } 
      , { name: "sMPlayback" } 
      );​​ 
</script> 
+0

我明白了。感谢小费。 – proyb2 2010-06-06 15:15:01