有没有办法在我的网站上添加褶边?

问题描述 投票:0回答:2

我无法访问 ruffle.js 上的代码,当我尝试使用其他方法时,它说扩展已被阻止,但 ruffle 已在这台计算机上运行,有人帮忙吗? “我的”代码是:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset='utf8'>
    </head>
    <body>
        <div id='ruffle'></div>
<script>
    window.RufflePlayer = window.RufflePlayer || {};

    window.addEventListener("DOMContentLoaded", () => {
        let ruffle = window.RufflePlayer.newest();
        let player = ruffle.createPlayer();
        let container = document.getElementById("container");
        container.appendChild(player);
        player.load("movie.swf");
    });
</script>
<script src="https://flash-games.penguinbotcoder.repl.co/ruffle/ruffle.js"></script>
<object width="600" height="400">
    <param name="movie" value="https://flash-games.penguinbotcoder.repl.co/flashgames/thinice.swf">
    <embed src="https://flash-games.penguinbotcoder.repl.co/flashgames/thinice.swf">
    </embed>
</object>
<script src="path/to/ruffle/ruffle.js"></script>
    </body>
    <div class=ruffle>
    </div>
    <p>This is a test page for flash content</p>
</html>

正如我在上面所说的,它只是不起作用:(

html css web flash ruffle
2个回答
1
投票

我不太明白到底是什么问题,但这是我从你的代码中注意到的: 您正在尝试通过 id

container
获取元素,但 HTML 中没有该元素,我认为您尝试使用 id
ruffle
的元素。

window.addEventListener("DOMContentLoaded", () => {
    let ruffle = window.RufflePlayer.newest();

    let player = ruffle.createPlayer();
    let container = document.getElementById("ruffle");
    container.appendChild(player);
player.load("movie.swf");
});

更新:
如果仍然无法正常工作,请尝试此示例代码并查看它是否加载 Flash 内容...

<!DOCTYPE HTML>
<html>
    <head> <meta charset='utf8'> </head>
    
    <body>
    
        <script src="https://flash-games.penguinbotcoder.repl.co/ruffle/ruffle.js"></script>
    
        <div id='ruffle'></div>
        
        <p>This is a test page for Adobe Flash content</p>
        
    </body>
    
    <script>
    
        window.RufflePlayer = window.RufflePlayer || {};
        window.addEventListener("DOMContentLoaded", start_Ruffle, false );
        
        function start_Ruffle()
        {
            let ruffle = window.RufflePlayer.newest();
            let player = ruffle.createPlayer();
            let container = document.getElementById("ruffle");
            container.appendChild(player);
            player.load("https://flash-games.penguinbotcoder.repl.co/flashgames/thinice.swf");
            
        }
        
    </script>

</html>

0
投票

确保您的 Ruffle 脚本路径和 Flash 文件可访问,因为我

https://flash-games.penguinbotcoder.repl.co/ruffle/ruffle.js
path/to/ruffle/ruffle.js
无法访问它们。 当前 Ruffle 的屏幕截图,位于
https://flash-games.penguinbotcoder.repl.co/ruffle/ruffle.js
返回 308 永久重定向

您可以尝试将 Ruffle 路径更新到位于

https://unpkg.com/@ruffle-rs/ruffle
的 CDN 版本或自行托管。

你的代码应该是这样的

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset='utf8'>
    </head>
    <body>
        <div id='ruffle'></div>
        <script>
            window.RufflePlayer = window.RufflePlayer || {};
            window.addEventListener("DOMContentLoaded", () => {
                let ruffle = window.RufflePlayer.newest();
                let player = ruffle.createPlayer();
                let container = document.getElementById("container");
            container.appendChild(player);
        });
        </script>
        <script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
        <object width="600" height="400">
            <param name="movie" value="https://flash-games.penguinbotcoder.repl.co/flashgames/thinice.swf">
            <embed src="https://flash-games.penguinbotcoder.repl.co/flashgames/thinice.swf" />
        </object>
        <p>This is a test page for flash content</p>
    </body>
</html>

请注意,我无法访问您的 Flash 文件。

© www.soinside.com 2019 - 2024. All rights reserved.