Written game (memory) works in Firefox, but not in Chrome or IE
SWSGKloss

Hello guys,

first I have to say thank you for the great engine and the perfect tutorials.

But I got a problem: coded a memory game like the one in the YouTube-tutorial, but on my machine it only works with Firefox, not with IE or Chrome.

My OS is Win10, I got the actual Java installed (8U111, x86 and x64).

What could possibly be the problem?

If you need further infos just let me know.

 

Greetings,

Florian

All 23 Comments
Gio

Hi

You certainly don't need Java for this :)

It sounds like it's a problem with the way you're opening your index.html. Firefox is more permissive, it allows you to run scripts that are on your local hard drive; Chrome and IE don't allow you to do that, for security reasons.

The best thing to do would be to put your files on a web server, and those restrictions will go away.

If you don't have access to a web server, you could create a local one. On windows, you could use our own prompt.js tool - after installing it, just use Windows File Explorer to go to your game's folder; right-click on the folder background and select prompt.js here. In the window that opens up, type server 2345. This will create a local web server on port 2345, so you can use any web browser to go to http://localhost:2345 to access your game.

Alternatively you can modify your Windows shortctut for Chrome to add the --allow-file-access-from-files command line argument. After closing all your Chrome windows and re-launching Chrome with that command line argument, the local script restrictions will go away. However I wouldn't recommend it, the other method is better and more secure. Those restrictions are there for a reason after all.

SWSGKloss

Okay, will check it on my webserver in a few mins and will report in after that.

Haven't thought it will be a big problem open it from my HDD.

Thx so far!

SWSGKloss

Okay, tested it after hosting all files.

Now it doesn't even work in Firefox. Crosschecked at 2 employees, it doesn't work on their browsers either.

 

Link: http://fkloss.lima-city.de/SWSG_Test/index.html

Gio

I think access permissions aren't set up correctly, it says

403 Forbidden

You don't have permission to access /SWSG_Test/scene1.wsc on this server.

SWSGKloss

Hm. Changed all permissons (for tests) to 777(rwx everyone).

But nothing changed. Damn Webspaces...

SWSGKloss

Okay, open it locally I detected the Following Errors in Chrome:

Maybe this helps?

 

SWSGKloss

I've hosted the actual Version so all of you are able to crosscheck it:

https://drive.google.com/file/d/0BxzYeFoMVEGEdXFOd2w4bnM2UkE/view?usp=sharing

Gio

Yes, that is the correct behavior - you cannot dynamically load local scripts in Chrome.

I downloaded the zip, created a local web server (as described above with prompt.js) and it works.

If you must open it locally in Chrome, you should really use the --allow-file-access-from-files command line argument... but hosting it on a web server will work, provided that all files are publicly accessible. You got quite close earlier, index.html was correctly set up so it could be accessed by anyone, but the other files were not.

SWSGKloss

Okay, online I should have changed every access to RWX for everyone one every file. Will double check it later...

SWSGKloss

So, with that little prompt.js tool (thanks for that, didn't knew it) it works in Chrome and FF.

Problem: IE ist Corporate-Standard. 

Last step! We will find it :-P

Checking the Settings atm...

SWSGKloss

Okay, just found another error.

 

Seems like IE11 doesn't support the method .call from the toString function?

Maybe you used an method which ist not supported in IE?

Crosschecked Edge, Chrome an FF - all three of them work propperly.

But no chance on getting it fixed in IE.

Gio

I think you're right, it looks like IE 11 and older do not like that code. I've just fixed it - the fix will be available in WADE 3.5.

If you need the fix sooner, you could add this bit of code in your index.html, after the wade.js script is included.

<script>
wade.isPlainObject = function(obj)
{
    var proto, Ctor;

    // Detect obvious negatives
    // Use toString to catch host objects
    if (!obj)
    {
        return false;
    }
    try
    {
        if (toString.call(obj) == '[object Object]')
        {
            return false;
        }
    }
    catch(e)
    {
        try
        {
            if (Object.prototype.toString.call(obj) == '[object Object]')
            {
                return false;
            }
        }
        catch (e)
        {
            return false;
        }
    }
    if (!obj)
    {
        return false;
    }
    try
    {
        if (toString.call(obj) !== '[object Object]')
        {
            return false;
        }
    }
    catch(e)
    {
        try
        {
            if (Object.prototype.toString.call(obj) !== '[object Object]')
            {
                return false;
            }
        }
        catch (e)
        {
            return false;
        }
    }

    proto = Object.getPrototypeOf(obj);

    // Objects with no prototype (e.g., `Object.create( null )`) are plain
    if (!proto)
    {
        return true;
    }

    // Objects with prototype are plain iff they were constructed by a global Object function
    Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
    return typeof Ctor === "function" && fnToString.call(Ctor) === objectFunctionString;
};
</script>

Thanks for reporting the problem.

SWSGKloss

Okay, good to know.

 

When will the 3.5 update be available? And how do I check the current WADE Version?

 

Greetings

Gio

The current version is 3.4. Calling wade.getVersion() tells you which version you're using - most likely 3.4.

When you open the online editor and a new version is available you'll be prompted to update, so you will know when it's available.

Anyway, no set dates, but some time around December 12th for WADE 3.5 - quite a few new features, it takes a bit of time.

SWSGKloss

Okay, then I have to change the index manually (Deadline for my project is the 15th).

 

I pasted your code into the index, now it works in FF but not in IE and Chrome.

Maybe wrong position or spellings in the code?

 

<!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, minimal-ui"/>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Wade Game Engine</title>

    <script src="wade.js"></script>
    
    <script>
        wade.isPlainObject = function(obj)
        {
            var proto, Ctor;
        
            // Detect obvious negatives
            // Use toString to catch host objects
            if (!obj)
            {
                return false;
            }
            try
            {
                if (toString.call(obj) == '[object Object]')
                {
                    return false;
                }
            }
            catch(e)
            {
                try
                {
                    if (Object.prototype.toString.call(obj) == '[object Object]')
                    {
                        return false;
                    }
                }
                catch (e)
                {
                    return false;
                }
            }
            if (!obj || toString.call(obj) !== "[object Object]")
            {
                return false;
            }
        
            proto = Object.getPrototypeOf(obj);
        
            // Objects with no prototype (e.g., `Object.create( null )`) are plain
            if (!proto)
            {
                return true;
            }
        
            // Objects with prototype are plain iff they were constructed by a global Object function
            Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
            return typeof Ctor === "function" && fnToString.call(Ctor) === objectFunctionString;
        };
    </script>

    <script>
        document.addEventListener('DOMContentLoaded', 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>

</body>
</html>

 

Also tested it when pasted after the addEventListener Method.

Gio

How does it not work, what errors do you get?

SWSGKloss

Okay, checked it again, now it works in chrome and ff, again not in IE.

 

Maybe we should try an remote control or stuff like that? Don't know where you live and if it's possible or included in your service ;-)

Gio

I'd like to help but I'd need to know what errors you have... or attach your app's zip file here and I'll run it in IE 11 to see what happens

SWSGKloss

Okay, attached is the current version with your edited code in it.

Errors ar the Following:

 

 

 

 

 

 

Gio

It looks like my code above didn't really fix it. I've now updated my previous post with something that does work

SWSGKloss

Yes! Finally!

Wow. Now it works perfect!

Wher is your "donate"-Button? ;-)

 

Thanks for your quick responses and all your effort you put into this. Lovely to see there are people out there who share their hobbys and knowledge with others.

 

Best wishes from Germany,

Florian

Gio

No worries, I'm glad it's working. It's also helped us fix some compatibility issues with IE11 (a platform that we don't use very often), making WADE more robust.

SWSGKloss

Sounds like a Win-Win-Situation :-)

Post a reply
Add Attachment
Submit Reply
Login to Reply