1

I want to be able to interpret or compile Javascript files, catching errors, etc. from Python programs. Javascript Files use the following syntax for ex.:

var a;
function Mul (){
  prompt(b);
  document.write(a*b);
}

I tried with SpiderMonkey but it seems to be unable to interpret "prompt", "document.write", etc. Help please.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Academia
  • 3,984
  • 6
  • 32
  • 49

1 Answers1

1

Stuff like document.write can't work since SpiderMonkey is not a browser. So there's no document, and no DOM. Likewise, you don't have a window, so no alerts or prompts. All this wouldn't make much sense in a command-line script...

You could build your own DOM parser in Python (assuming you actually have a web page to parse in the first place), and create a document object yourself, but that would probably be a lot of work for very little return.

dda
  • 6,030
  • 2
  • 25
  • 34