macaddress.jsp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. <a href="#" onclick="macs.getMacAddress();"> Get"first"MAC Address</a>
  11. <br/>
  12. <br/>
  13. <a href="#" onclick="macs.getMacAddressesJSON();"> Get all MAC Addresses</a>
  14. <!--[if !IE]> Firefox and others will use outer object -->
  15. <embed type="application/x-java-applet"
  16. name="macaddressapplet"
  17. width="0"
  18. height="0"
  19. code="MacAddressApplet"
  20. archive="macaddressapplet.jar"
  21. pluginspage="http://java.sun.com/javase/downloads/index.jsp"
  22. style="position:absolute; top:-1000px; left:-1000px;">
  23. <noembed>
  24. <!--<![endif]-->
  25. <!---->
  26. <object classid="clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA"
  27. type="application/x-java-applet"
  28. name="macaddressapplet"
  29. style="position:absolute; top:-1000px; left:-1000px;"
  30. >
  31. <param name="code"value="MacAddressApplet">
  32. <param name="archive"value="macaddressapplet.jar">
  33. <param name="mayscript"value="true">
  34. <param name="scriptable"value="true">
  35. <param name="width"value="0">
  36. <param name="height"value="0">
  37. </object>
  38. <!--[if !IE]> Firefox and others will use outer object -->
  39. </noembed>
  40. </embed>
  41. <!--<![endif]-->
  42. <script type="text/javascript">
  43. var macs = {
  44. getMacAddress : function()
  45. {
  46. document.macaddressapplet.setSep("-");
  47. alert("Mac Address ="+ document.macaddressapplet.getMacAddress() );
  48. },
  49. getMacAddressesJSON : function()
  50. {
  51. document.macaddressapplet.setSep(":");
  52. document.macaddressapplet.setFormat("%02x");
  53. var macs = eval( String( document.macaddressapplet.getMacAddressesJSON() ) );
  54. var mac_string ="";
  55. for( var idx = 0; idx < macs.length; idx ++ )
  56. mac_string +="t"+ macs[ idx ] +"n";
  57. alert("Mac Addresses = n"+ mac_string );
  58. }
  59. }
  60. </script>
  61. </body>
  62. </html>