开发者

Java Applet: how to simulate an url has been clicked?

Basically I want my Java Applet to simulate an url has been clicked, once a certain event listener has been executed.

Say, before I have a link in html:

<a href='destinationpage.php?pid=1001' target='rightFrame' />

I'd like to keep the s开发者_如何学JAVAame link to php intact, and when Applet actually invoke the click simulation method, the "target" attribute can also be used to control the behavior.

Similar SO thread found at here, but it doesn't have an answer.

I have little experience in this area, but I am okay with Java programming so long as someone can give me the suggestion of where to get started with.

Many thanks in advance.

Edit:

Okay, tried to get JSObject from the netscape.javascript package to work, added plugin.jar into CLASSPATH, unfortunately I finally got an ExceptionInInitializerError, so this approach failed, unless I can know how to debug in such a mess...


You could call the url directly in the applet but if you want to reference the link in the page something like the following should work. I have not tested this though.

getAppletContext().showDocument(new URL("javascript:function() {
  document.getElementById('mylink').click();
}"));
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜