问题
Cross-posted from https://github.com/tmpvar/jsdom/issues#issue/127
I will post a minimal test case in the next day or so - but I wanted to see if anyone else had the same problem - or if (more likely) if I am doing something stupid.
I'm using NodeJS v2.6 on Ubuntu 10.04 AMD64 and jsdom@0.1.23.
var file = readFileSync("./www/index.html", "utf8"); var window = jsdom.jsdom(file).createWindow();
All inline scripts run, but complain about missing variables which should be supplied by the external scripts.
I have tried setting a url in the options and I have tried using full (http://...) urls in the src attributes,
I have tried jQuerify (using default jQuery path) and that works fine, though it only brings in jQuery and I'm still missing all of the other scripts.
Any pointers before I post failing code/urls?
Thanks,
Chris.
回答1:
As of jsdom 0.2.0 this has become much easier. Please see the "Easy mode" section in the readme. jsdom.env() will not execute scripts found in the page by default making what you are trying to do, much easier.
回答2:
I removed all in-line Javascript from the page - luckily the page is under my control.
来源:https://stackoverflow.com/questions/4711655/jsdom-not-loading-or-not-running-external-scripts-in-page