Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Kerri Gonzalez   on Jul 22 In Java Category.

  
Question Answered By: Faith Hughes   on Jul 22

I run it in ms internet explorer 5.5 and it worked ok,
it return  an InetAddress object.
And if I call an getHostName() method:

alert(a.getHostName());

it return my pc´s name.

If it returns  null , maybe the applet  havn´t been
initialited yet.
Try put it in a body tag and in the function
window.onload() call to foo()
Check the jvm in your browser too.

This works for me:
-------------------------------------------
<html>
<body>
<applet code="ComputerName.class" width="100"
height="100"></applet>
</body>
</html>

<script language="JavaScript">

function window.onload(){
foo();
}

function foo() {
with(document.applets[0]) {
var a = getVariable();
alert(a.getHostName());
}
}
</script>
-------------------------------------------

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on trying to return the computername using applet Or get search suggestion and latest updates.


Tagged: