开发者

How do I tell which web browser a Java applet is running under, from the applet? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to get browser type and version from within an applet?

I need to get the web brow开发者_如何学运维ser version / vendor that an applet is running in. I can get the Java version and the OS from the System properties, but I don't see anything similar for the browser.


You need to use Javascript and modify param values.

Browser info can be fetched using navigator object

few of the methods

navigator.appName
navigator.appVersion
navigator.userAgent

and pass those values into applet tags dynamically,which are actual parameters of method in an applet.

a small but good example can be found here on integrating javascript and java applets. http://www.ibiblio.org/java/course/week5/16.html

after which you can set values using following snippet.

<applet >

<PARAM id="browserAgent" name="browserAgent" value=""/>

</applet>

<script type="text/javascript">

document.getElementById("browserAgent").value=navigator.userAgent;

</script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜