Getting the contents of – Jonathan Lonowski Jun 14 '14 at 17:20

  • @m93a Do you access the html document using `file` scheme? If yes, `XMLHttpRequest` to other local files will work on firefox. – Oriol Jun 14 '14 at 17:34
  • Yeah, I've got it. It's a pitty @Quentin marked this as a duplicate, I'd post the answer. Yes, it's _de facto_ the same problem but nobody posted the exact code. http://pastebin.com/VJssy2p1 – m93a Jun 14 '14 at 18:38
  • @m93a — That code won't work. You'll hit the same origin policy as mentioned by Jonathan Lonowski. – Quentin Jun 14 '14 at 18:41
  • @Quentin As I've already said, it's not for **cross-origin** requests. It works if both html and script files are on the same website or both in a local folder. Ordinary javascript would also fail to run if it's cross-origin. – m93a Jun 14 '14 at 18:44
  • @m93a — Most browsers treat any other local file as a different origin, even if they are in the same local directory. – Quentin Jun 14 '14 at 18:45
  • Chrome, Internet Explorer and Opera (which is three of the top five) – Quentin Jun 14 '14 at 18:58
  • 1
    As for reasons not to do it… "Here, open this email attachment, it is a perfectly harmless HTML document". – Quentin Jun 14 '14 at 19:02
  • 0 Answers0