0

My problem is maybe specific and not a duplicate of this question.

I'm trying to load a HTML file and a script from Copy (which is a Dropbox-like) but since Copy declares those files with mime-type text/plain with a header X-Content-Type-Options: nosniff I get the error within Chrome strict MIME type checking is enabled.

I decided to load the content within a script tag. This is my attempt:

z = new XMLHttpRequest(); /* this is for the script.js file which is actually
                            jquery.min.js with bootstrap.min.js */
z.onreadystatechange = function () {
    if (z.readyState == 4) {
        if (z.status == 200) {
            x = new XMLHttpRequest(); /* this is for the HTML file */
            x.onreadystatechange = function () {
                if (x.readyState == 4) {
                    if (x.status == 200) {
                        document.write(x.responseText.replace("\x3Cscript type=\"text/javascript\" src=\"xfiles/sys/script.js\">\x3C/script>", "\x3Cscript type=\"text/javascript\">" + z.responseText + "\x3C/script>").replace("<head>", "<head><base href='http://copy.com/N9NLnrlQvzer/residanat/'/>"));
                    }
                }
            };
            x.open("GET", "http://copy.com/N9NLnrlQvzer/residanat/index.html", true);
            x.send(null);
        }
    }
};
z.open("GET", "http://copy.com/N9NLnrlQvzer/residanat/xfiles/sys/script.js", true);
z.send(null);

The content is actually loading but I get a funny result.

Any clues about what went wrong?

Thanks!

Community
  • 1
  • 1
pr.nizar
  • 641
  • 6
  • 20
  • "funny result"? Was that the best description you could come up with ! – adeneo Apr 07 '14 at 14:15
  • I'm sorry but I could not find any that matchs what I got. Could you please check it and describe what you found? – pr.nizar Apr 07 '14 at 14:17
  • Describe us what output do you see. Check for JS errors in the console. What is the response received? –  Apr 07 '14 at 14:36
  • The `script.js` file is loaded then the `index.html` file then modification of the script tag is done as expected with content of the `script.js` instead of the `src` attribute but the body content is filled with script (from the `script.js` file). I really don't know how to desribe what happened! Check it and you'll see.. – pr.nizar Apr 07 '14 at 14:50
  • @adeneo How could I be more specific? Have you got a clue?! I bet you found it funny too.. ^^ – pr.nizar Apr 07 '14 at 14:54

0 Answers0