internal and external network simultaneous access problem: Using JS to determine access to computer IP

Source: Internet
Author: User
js| Access | issues

I built two servers, a database server, a Web server on the intranet. And let network management allude to the network IP to the Web server, so that the external network can be accessed simultaneously. But this creates the problem, the Web server takes the data is uses the intranet the relative address, such extranet accesses when cannot obtain the data, only can display the frame. If the database server also mapped, then the intranet can not access, so I can not debug. If you put two servers together, then the speed of the operation will be affected, and now the boss does not want to invest money, after all, just a demo. And the two machines moved to the laboratory network computer room directly to the outside can also be resolved, but the network room is closed, access control card, so I can not often go in to modify.

Think carefully about it, feel that make a judgment should be able to solve this problem, as long as the decision to access the intranet IP or extranet IP, according to the judgment to carry out the corresponding operation

Check the data found with JS good, because JS access to the IP has an advantage is that it gets the IP set, if the computer through the LAN, then it gets the computer LAN IP, and unlike the ASP request is the computer connected to the Internet IP.

Code (is copied from someone else, but you can refer to the:) )

<HTML>
<meta http-equiv= "Content-type" content=; text/html gb2312
<title>js Get client ip</title>
<body>
<script type= "text/ JavaScript "language=" JavaScript
<!--
function getlocalipaddress ()
{
    var obj = null;
    var rslt = "";
    try
    {
        obj = new ActiveXObject ("Rcbdyctl.") Setting ");
        rslt = obj. getipaddress;
        obj = null;
   }
    catch (E)
    {
       //exception occurrence
   }   
    return rslt;
}
document.write ("Your IP is:" + getlocalipaddress ());
//-->
</script>
</body>

It is said that the warning may appear in use, but this is only testing, should not be in the way, hehe:)



Related Article

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.