简体   繁体   中英

unable to load script HTML and javascript

So I have an index.html file with the following text:

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>

    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Wade Game Engine</title>

    <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
    <script src="wade_1.5.js"></script>
    <script src="wade.ifx_1.0.js"></script>
    <script src="wade.particles_1.0.1.js"></script>

    <script>
        $(document).ready(function() {
            wade.init('app.js');
        });
    </script>
</head>

<body>
    <div id="container" style="border:0; width:800px; height:600px;">
        <div id="wade_main_div" width="800" height="600" tabindex="1"></div>
    </div>
    <div id="chromeFix"></div>
    <div id="chromeFix2"></div>
</body>
</html>

When I try to run this using a browser (tried with google chrome and internet explorer) it just pops a window saying:

unable to load main app script app.js

So I assume the problem is here:

<script>
    $(document).ready(function() {
        wade.init('app.js');
    });
</script>

But I can't understand what's the problem... Could anyone help me with this? It's driving me insane!

It could be that there is an error in app.js (so it isn't a valid .js file), or it could be that your browser is not allowing you to load local scripts asynchronously.

With Chrome, you could add --allow-file-access-from-files as a command line argument. Note that you only need to do this if you're using local files - if the files are hosted on a web server, it should just work without all this.

Alternatively, you can include app.js with the other script tags that you have in your HTML file, and just call wade.init() without passing 'app.js' to it

Do you have an app.js file? I haven't used this game engine but looking at its documentation , it appears that the init() method takes a mandatory parameter appScript , containing the filename of the app. In your case this would be app.js .

Make sure that you have the file app.js included in the same directory as your index.html file.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM