0

A bit of an unusual setup:

I'm writing in an html page that in turn loads another html page, parses it, analyzes it, and displays information about it.

The parsing is fairly easy using jQuery. I just need to figure out how to load the external page - that is, when page A is displayed in the browser, it needs to load page B, analyze page B, and display information about page B.

Both pages are local (not served via a web server).

Both load and ajax from jQuery run into the cross-origin permission issue:

XMLHttpRequest cannot load file://localhost/Users/me/test.html. Origin null is not allowed by Access-Control-Allow-Origin.

I can load the page with a script tag, but then I don't know how to access it so I can parse it:

<script type="text/html" src="test.html"></script>

Any ideas?

Parand
  • 102,950
  • 48
  • 151
  • 186
  • "I'm doing X. How do I do X?" This is most peculiar. What problem are you trying to solve? Why not approach it conventionally? – Lightness Races in Orbit Dec 15 '12 at 19:36
  • What is the conventional approach? – Parand Dec 15 '12 at 19:38
  • Are you trying $.load with a relative url (/Users/me/test.html) or a full url (http://localhost/User/me/test.html)? – qooplmao Dec 15 '12 at 19:40
  • @Parand: I don't know yet. What are you trying to do? – Lightness Races in Orbit Dec 15 '12 at 19:41
  • I was trying load with the relative url. I just tried with the full url and ran into the same issue. – Parand Dec 15 '12 at 19:43
  • @LightnessRacesinOrbit Exactly what I've described in the question: use html/javascript to parse a local file and display information about it. There are many other approaches (eg. I can write the parser/analyzer in python and generate the html), but I'd prefer to keep it html/javascript based to reduce dependencies and make it easily portable. – Parand Dec 15 '12 at 19:45
  • 1
    @Parand: No, _what are you trying to do_? Not _how_ you think you should do it. – Lightness Races in Orbit Dec 15 '12 at 19:58
  • possible duplicate to [Ways to circumvent the same-origin policy](http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy) – feeela Dec 15 '12 at 22:00

1 Answers1

0

Have you thought about using JavaScript/jQuery to create an iframe? (You can use CSS to make the iframe hidden to the end user.) Then you can listen for the iframe's onload event, and parse it through the iframe's contentDocument element (I believe).

JacobEvelyn
  • 3,901
  • 1
  • 40
  • 51