Flex gets IP and Pcname sample code through JS _flex

Source: Internet
Author: User
Tags xmlns
This is the way to get the IP and pcname in JS, now put it in the Flex startup template. Look at the code:
Copy Code code as follows:

function Getclientpcname ()
{
"Initialize and script ActiveX controls that are not marked for security in your browser's Internet Options," set to Enabled! \ n \ nplease then refresh the landing page! "
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;
}

This code is placed in the HTML template,

Remember that the template is not bin-debug, why everyone is more clear ah

Flex Foreground Code
Copy Code code as follows:

<?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=" 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>
<supportClasses:AttachmentLayout/>
</s:layout>
<fx:Declarations>
<!--place non-visual elements (such as services, value objects) here-->

</fx:Declarations>
<mx:datagrid x= "186" y= "173" >
<mx:columns>
<mx:datagridcolumn headertext= "Column 1" datafield= "col1"/>
<mx:datagridcolumn headertext= "column 2" datafield= "col2"/>
<mx:datagridcolumn headertext= "Column 3" datafield= "Col3"/>
</mx:columns>
</mx:DataGrid>
</s:Application>

Externalinterface realizes the communication between JS and as
This method can only be implemented under IE, and must also set IE security level

The results of the operation are 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.