Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:42:09+00:00 2026-05-24T13:42:09+00:00

I am new to HTML/Javascript, as well as coding in general so bear with

  • 0

I am new to HTML/Javascript, as well as coding in general so bear with me :). I am trying to create a “Spot the Difference” game in html5 using javascript. Everything is local (on my machine). I have two pictures, of the same size, one with differences. To generate data about the clickable fields, I have a java program that reads both of the images and outputs all of the positions in which pixels are different into a XML file. My plan was to then use this XML file with my javascript to define where the user could click. However, it appears (correct me if I’m wrong) that javascript cannot read local XML files for security reasons. I do not want to use an ActiveXObject because I plan on putting this onto mobile devices via phone gap or a webkit object. Does anyone have a better approach to this problem, or perhaps a way to read local XML files via javascript? Any help would be greatly appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:42:11+00:00Added an answer on May 24, 2026 at 1:42 pm

    If you are planning to put this into a smart phones (iOS and Android) and read local files, I have done similar things with JSON (yes, please don’t use XML).

    1. Convert your output to JSON
    2. Put this as part of your application package. For example, in Android, I put it as part of the .apk in /appFiles/json
    3. Create a custom content provider that would read the local file. I create mine as content:// but you create whatever scheme you want. You could leverage android.content.ContentProvider in order to achieve custom URL Scheme. iOS has its own way to create custom scheme as well. The implementation simply read your local storage and give the content
    4. To read it from Javascript, I simply call ajax with the custom scheme to get the json file. For example content://myfile/theFile.json simply redirect me to particular directory in local storage with /myfile/theFile.json appended to it

    Below is the sample to override openFile() in the ContentProvider

    
    
        public ParcelFileDescriptor openFile (Uri uri, String mode) {
            try {
                Context c = getContext();
                File cacheDir = c.getCacheDir();
                String uriString = uri.toString();
                String htmlFile = uriString.replaceAll(CUSTOM_CONTENT_URI, "");
    
                // Translate the uri into pointer in the cache
                File htmlResource = new File(cacheDir.toString() + File.separator +  htmlFile);
    
                File parentDir = htmlResource.getParentFile();
                if(!parentDir.exists()) {
                    parentDir.mkdirs();
                }
    
                // get the file from one of the resources within the local storage
                InputStream in = WebViewContentProvider.class.getResourceAsStream(htmlFile);
    
                // copy the local storage to a cache file
                copy(in, new FileOutputStream(htmlResource));
                return ParcelFileDescriptor.open(htmlResource, ParcelFileDescriptor.MODE_READ_WRITE);
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
        }
    
    

    I hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new web app that is packaged as a WAR as part
I have found this example on StackOverflow: var people = new List<Person> { new
I'm trying to build a Chrome browser extension, that should enhance the way the
I am attempting to pull some information from my tnsnames file using regex. I
I have a script that appends some rows to a table. One of the
IE is giving me an undefined NAN when i try to view the calender...
This is beyond both making sense and my control. That being said here is
I would like to update my SQL lite database with the native update-method of
I want to use a temp directory that will be unique to this build.
I have a project that adds elements to an AutoCad drawing. I noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.