The information in this article applies to:
SUMMARYThis article describes the functions understood by Internet Explorer when you use a Proxy AutoConfiguration (.pac) file. The examples included in this article are taken directly from the documentation that is included with the Microsoft Internet Explorer Administration Kit (IEAK). MORE INFORMATION
You can use a .pac file to centrally control the proxy settings of your browser client. You can set addresses that are bypassed by the proxy server, specify which proxy server the client uses based on the subnet, and specify which proxy server is used depending on the requested Uniform Resource Locator (URL).
JavaScript or JScript Auto-Proxy ExamplesThe following examples show how you can use a .pac file to specify an auto-proxy URL. To use these functions, you must change the proxy names, port numbers, and Internet Protocol (IP) addresses.NOTE: The isInNet(), isResolvable(), and dnsResolve() functions query a DNS server. References to Object Model objects, properties, or methods cause the .pac file to run unsuccessfully. For example, all of the following references cause the .pac file to run unsuccessfully on Internet Explorer:
Example 1: Local Hosts Connect Directly, All Others Connect Through a ProxyThe following function checks to see if the host name is a local host. If the host name is a local host, the function checks to see if the connection is direct. If the host name is not a local host, the connection is through the proxy.
The isPlainHostName() function checks to see if there are any dots in the host name. If so, it returns false; otherwise, it returns true.
Example 2: Hosts Inside the Firewall Connect Directly, Outside Local Servers Connect Through a ProxyThe following function checks to see if the host is either a "plain" host name (meaning the domain name is not included) or part of a particular domain (.company.com), but the host name is neither www nor home. NOTE: The localHostOrDomainIs() function is run only for URLs in the local domain. The dnsDomainIs() function returns true if the domain of the host name matches the domain that is given.
Example 3: Connect Directly if Host Is Resolvable, Otherwise Connect Through a ProxyThe following function requests that the DNS server resolve the host name that is passed to it. If the DNS server can resolve the host name, a direct connection is made. If the DNS cannot resolve the host name, the connection is made through a proxy. This function is useful when you use an internal DNS server to resolve all internal host names. NOTE: The isResolvable() function queries a DNS server.
Example 4: Connect Directly if Host Is in Specified Subnet, Otherwise Connect Through a ProxyThe following function compares a given IP address pattern and mask with the host name. This function is useful if certain hosts in a subnet should be connected directly and others should be connected through a proxy. NOTE: The isInNet() function queries a DNS server.
The isInNet function (host, pattern, mask) returns true if the host IP address matches the specified pattern. The mask indicates which part of the IP address to match (255=match, 0=ignore). Example 5: Determine Connection Type Based on Host DomainThe following function specifies a direct connection if the host is local. If the host is not local, this function determines which proxy to use based on the host domain. This function is useful if the host domain name is one of the criteria for proxy selection.
The shExpMatch(str, shexp) function returns true if str matches the shexp using shell expression patterns.
Example 6: Determine Connection Type Based on Protocol Being UsedThe following function extracts the protocol being used and makes a proxy selection accordingly. If no match is made on the protocol, a direct connection is made. This function is useful if the protocol being used is one of the criteria for proxy selection.
The substring() function extracts the specified number of characters from a string.
Example 7: Determine Proxy Setting By Checking to See if Host Name Matches IP AddressThe following function makes a proxy selection by translating the host name into an IP address and comparing it to a specified string. NOTE: The dnsResolve() function queries a DNS server.
Example 8: Connect Through a Proxy if Host IP Address Matches Specified IP Address, Otherwise Connect DirectlyThe following function is another way to make a proxy selection based on specifying an IP address. This example (unlike example 7) uses the function call to explicitly obtain the numeric IP address (example 7 uses the dnsResolve() function to translate the hostname into the numeric IP address).
The myIpAddress() function returns the IP address (in integer-dot format) of the host on which the browser is running.
Example 9: Connect Through a Proxy if Any Dots Exist in the Host Name, Otherwise Connect DirectlyThe following function checks to see how many dots are in the host name. If there are any dots in the host name, the connection is made through a proxy. If there are no dots in the host name, a direct connection is made. This is another way to determine connection types based on host name characteristics.
The dnsDomainLevels() function returns an integer equal to the number of dots in the host name.
Example 10: Specify Days of the Week to Connect Through a Proxy, Other Days Connect DirectlyThe following function determines the connection type by specifying days of the week that are appropriate for a proxy. Days that do not fall between these parameters use a direct connection. This function is useful in situations where you might want to use a proxy when traffic is heavy and allow a direct connection when traffic is light.
The weekdayRange( day1 [,day2] [,GMT] ) function tells you if the current system time falls within the range specified by the parameters day1, day2, and GMT. Only the first parameter is necessary. The GMT parameter sets the times to be taken in GMT, rather than in the local time zone.
NOTE: Where the function is called with day1 == day2, previous versions of Internet Explorer yield results that differ from Netscape Navigator. Specifically, previous versions of Internet Explorer interpret this day range as an entire week, while Internet Explorer 5 and Netscape Navigator interpret the range as a single day. For example, if the current day is Monday, the call weekdayRange("TUE", "TUE") returns true on previous versions of Internet Explorer and false on Internet Explorer 5 and Netscape Navigator. NOTE: The Proxy AutoConfiguration specification is from Netscape. Netscape supports a few more functions that are not listed in the IEAK documentation. These extra functions may not function properly in Internet Explorer. To view the Netscape documentation, visit the following Web site: http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.htmlThe third-party contact information included in this article is provided to help you find the technical support you need. This contact information is subject to change without notice. Microsoft in no way guarantees the accuracy of this third-party contact information. The third-party products discussed in this article are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability. Additional query words: pac FindProxyForURL jvs js autoproxy fail fails
Keywords : kbenv msiew95 msient msiew98 |
Last Reviewed: January 4, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |