How do I Disable the disable html5 file:/// protocol check

Get help using Construct 2

Post » Tue May 19, 2015 1:10 pm

Hi, When c2 project html5 is exported, I'm not able to run it locally because c2 [1] checks for file:/// protocol and won't allow run. How can I disable this behaviour?

[1]
<div id="c2canvasdiv">

<!-- The canvas the project will render to. If you change its ID, don't forget to change the
ID the runtime looks for in the jQuery events above (ready() and cr_sizeCanvas()). -->
<canvas id="c2canvas" width="1280" height="720">
<!-- This text is displayed if the visitor's browser does not support HTML5.
You can change it, but it is a good idea to link to a description of a browser
and provide some links to download some popular HTML5-compatible browsers. -->
<h1>Your browser does not appear to support HTML5. Try upgrading your browser to the latest version. <a href="http://www.whatbrowser.org">What is a browser?</a>
<br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>
<a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>
<a href="http://www.google.com/chrome/">Google Chrome</a><br/>
<a href="http://www.apple.com/safari/download/">Apple Safari</a><br/>
<a href="http://www.google.com/chromeframe">Google Chrome Frame for Internet Explorer</a><br/></h1>
</canvas>

</div>

Thanks,
-Hossein.
B
3
Posts: 8
Reputation: 191

Post » Tue May 19, 2015 8:54 pm

You need to define what you mean by locally.
If you try to start the index.html, and you get a warning , that is C2 telling you that using it outside a browser is a bad idea.
If it doesn't run, or you get some other error then your system is set up to not run scripts which is a good idea.
If you want to run the file after export, you can google how to setup a server on your own system, or upload it to a host, or portal like the arcade.
There are many different ways to go, but again running a plain html5 game on the desktop is a bad idea.
Image ImageImage
B
169
S
50
G
174
Posts: 8,330
Reputation: 110,804

Post » Wed May 20, 2015 10:12 am

The message is correct: the game won't run from disk. Removing the error message won't fix this, you'll just have a broken game that does not tell you why it's broken.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635

Post » Thu May 21, 2015 12:36 pm

Well, I have created a simple android app. In the assets folder. In the assets folder, I have dropped-in all the c2 html5 exported files. Next, for my webview, I have enabled javascript and set the setWebChromeClient and the setWebViewClient. When I try to run the app, I get a message that says: "Exported games won't work until you upload them. (When on the file:/// protocol, browsers block many features from working for security reasons.).

Above also happens when I directly run that from a computer.

I just want to disable this default behaviour.
B
3
Posts: 8
Reputation: 191

Post » Thu May 21, 2015 12:53 pm

You should use the Cordova export for Android-based apps using a webview, not the HTML5 export (which is designed for websites). Cordova already does all of that as well, so you only need to build it - no need to write the webview integration yourself.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635

Post » Thu May 21, 2015 6:06 pm

Okay, I think I got it resolved. The issue with exporting for Cordova and then using XDK is that the generated .apk gets too large; about 30mb. For those interested, here is what I did:

1. Export for Amazon - select option to run on own server
2. Created a simple Android app that basically has a webview and loads index.html as shown below. Built the .apk and instead of a .30mb .apk, I now have 5mb .apk for my sample app:

webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.loadUrl("file:///android_asset//index.html");

-Hossein.
B
3
Posts: 8
Reputation: 191


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 41 guests