Http://blog.csdn.net/dragonzoebai/article/details/9715011
This is the method to get the IP address and pcname in JS. Now you can put it in the flex launch template. Check the Code:
Function getclientpcname () {// "set" enable "for" Initializing ActiveX controls that are not marked as secure and running scripts "in the Internet option of your browser "! \ N and then refresh the page to log on! "Var wshshellpcname = new activexobject (" wscript. network "); var computername = wshshellpcname. computername; return computername;} function getclientip () {var wshshellip = new activexobject ("rcbdyctl. setting "); var IP = wshshellip. getipaddress; return IP ;}
Put this code in the HTML template,
Remember that the template is not Bin-Debug. The reason is clear.
Flex front-end code
<? XML version = "1.0" encoding = "UTF-8"?> <S: Application xmlns: FX = "http://ns.adobe.com/mxml/2009" xmlns: S = "Library: // ns.adobe.com/flex/spark" xmlns: MX = "Library: // ns.adobe.com/flex/mx" xmlns: supportclasses = "com. ESRI. AGS. skins. supportclasses. * "minwidth =" 955 "minheight =" 600 "creationcomplete =" Init () "> <FX: SCRIPT> <! [CDATA [import MX. controls. alert; Public Function Init (): void {var strpcname: String = externalinterface. call ("getclientpcname"); var strpcid = externalinterface. call ("getclientip"); MX. controls. alert. show (strpcname + "" + strpcid);}]> </FX: SCRIPT> <s: layout> <suppclasclasses: attachmentlayout/> </S: layout> <FX: declarations> <! -- Place non-visual elements (such as services and value objects) Here --> </FX: declarations> </S: Application>
Externalinterface implements communication between JS and
This method can only be implemented in IE, And the IE security level must be set.
The running result is as follows: