2010-06-06 53 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