Flex obtains the IP address and pcname through JS

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.