-1

我可以在 test.php 中仅对这段代码执行 JavaScript

  <script type="text/javascript" src="http://loveslgirls.com/Flash Mp3 Player/project/deploy/js/swfobject.js"></script> 
    <script type="text/javascript">
  
        // JAVASCRIPT VARS
        // the path to the SWF file
        var swfPath = "http://loveslgirls.com/Flash Mp3 Player/project/deploy/preview.swf";
        //swfPath += "?t=" + Date.parse(new Date()); // uncomment this line to activate cache buster        
        
        // stage dimensions
        var stageW = 560;//560//"100%"; // minimum is 450
        var stageH = 300;//400;//"100%"; // minimum is 260
        
        
        // ATTRIBUTES
        var attributes = {};
        attributes.id = 'FlashComponent';
        attributes.name = attributes.id;
        
        // PARAMS
        var params = {};
        params.bgcolor = "#333333";
        params.allowfullscreen = "true";
        params.allowScriptAccess = "always";            
        //params.wmode = "transparent";
        

        /* FLASH VARS */
        var flashvars = {};
        
        /// if commented / delete these lines, the component will take the stage dimensions defined 
        /// above in "JAVASCRIPT SECTIONS" section or those defined in the settings xml         
        flashvars.componentWidth = stageW;
        flashvars.componentHeight = stageH;                         
        
        /// path to the content folder(where the xml files, images or video are nested)
        /// if you want to use absolute paths(like "http://example.com/images/....") then leave it empty("")
        // Also, if you want the embed code to work correctly you'll need to set the an absolute path for pathToFiles, like this: http://www.yourwebsite.dom/.../mp3gallery/
        flashvars.pathToFiles = "http://loveslgirls.com/Flash Mp3 Player/";
        flashvars.xmlPath = "project/deploy/mp3gallery/xml/settings.xml";
        flashvars.contentXMLPath = "project/deploy/mp3gallery/xml/mp3gallery.xml";
                    
        /** EMBED THE SWF**/
        swfobject.embedSWF(swfPath, attributes.id, stageW, stageH, "9.0.124", "http://loveslgirls.com/Flash Mp3 Player/project/deploy/js/expressInstall.swf", flashvars, params, attributes);

</script>

    <table width="100%" height="100%" cellpadding="0" cellspacing="0">
        <td align="center">
            
            <!-- this div will be overwritten by SWF object -->     
            <div id="FlashComponent">
                <p>In order to view this object you need Flash Player 9+ support!</p>
                <a href="http://www.adobe.com/go/getflashplayer">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player"/>
                </a>
            </div>
    
        </td>
    </table>

但是当我将它添加到一个更复杂的 php 文件中时,它不会执行。它说:

Uncaught ReferenceError: ST is not defined Uncaught TypeError: Object [object DOMWindow] has no method 'addEvent'

如何将此播放器添加到我的复杂页面?

4

1 回答 1

0

看起来您是在元素出现在页面上之前调用脚本。您调用的方法是否处理 onload?如果不是,您应该在您引用的元素之后添加脚本,在 document.ready 上调用它,或者添加脚本 onload。

于 2012-04-27T12:25:41.427 回答