server-side jQuery
server-side jQuery
Hello,
I have been trying out the code from http://ejohn.org/blog/bringing-the-browser-to-the-server/
as a solution for doing server side javascript with dom parsing/
manipulation. The sample code works fine
1. load("env.js");
2. window.location = "http://alistapart.com/";
3. window.onload = function(){
4. load("dist/jquery.js");
5. print("Newest A List Apart Posts:");
6. $("h4.title").each(function(){
7. print(" - " + this.textContent);
8. });
9. };
but if i change window.location to other urls (i tried a couple) i get
an error:
java -jar js.jar test0.js
Exception in thread "Thread-0" org.mozilla.javascript.EcmaError:
TypeError: Cannot call method "createEvent" of null
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3350)
at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:
3340)
at
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:
3356)
at
org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:
3375)
at
org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:
3394)
at
org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:
2026)
at
org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:
117)
at org.mozilla.javascript.gen.c2._c4(Unknown Source)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at
org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:
119)
at org.mozilla.javascript.gen.c2._c107(Unknown Source)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:
393)
at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
2834)
at org.mozilla.javascript.gen.c2.call(Unknown Source)
at org.mozilla.javascript.Context.call(Context.java:548)
at
org.mozilla.javascript.JavaAdapter.callMethod(JavaAdapter.java:507)
at adapter1.run(<adapter>)
at java.lang.Thread.run(Thread.java:619)
What can be done about this?
thank you,
Slava