开发者

accessing Browser's javascript from Java applet with MS Internet Explorer

I'm using JSObject plugin to w开发者_Python百科rite a cookie through the java applet and it worked with SUN's Java.

but, With MS JVM the javascript command returning undefined

I'm issuing the following from my Applet:

String s1 = "document.cookie='logged=1'";
aobj = new Object[] { s1 };
JSObject.getWindow(MyAppletWindow).call("eval", aobj);

any clue?


First, I'm not entirely certain the Microsoft VM supports LiveConnect, which is required for JavaScript<->Java communication.

Further, the Microsoft VM only supported up to version 1.1 of Java. It is severely outdated and most likely not loading your applet anyway (do you see the famous typo applet not inited in IE's status bar?). In fact, even if you were using only 1.1-compatible libraries.. if you're using a recent compiler, you would have to jump through some hoops to even make it loadable by a 1.1 VM:

javac -source 1.1 -target 1.1 Foo.java

In summary, the Microsft VM is very old and you should target the Sun VM instead (you can use an object tag to enforce this, read this article for more information)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜