-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 が定義されていません Uncaught TypeError: Object [object DOMWindow] has no method 'addEvent'

このプレーヤーを複雑なページに追加するにはどうすればよいですか?

4

1 に答える 1

0

要素がページに表示される前にスクリプトを呼び出しているようです。呼び出しているメソッドは onload を処理しますか? そうでない場合は、参照している要素の後にスクリプトを追加するか、document.ready で呼び出すか、スクリプト onload を追加する必要があります。

于 2012-04-27T12:25:41.427 に答える