frosty5656
asked on
Change PROXY
how can i change my proxy server useing javascript
Ns Only:
function readPref(pref) {
var targ = netscape.security.Target.f indTarget( "Universal Preference sRead");
var mgr = netscape.security.AppletSe curity.get PrivilegeM anager();
mgr.enablePrivilege(targ);
return navigator.preference(pref) ;
}
function writePref(pref,val) {
var targ = netscape.security.Target.f indTarget( "Universal Preference sWrite");
var mgr = netscape.security.AppletSe curity.get PrivilegeM anager();
mgr.enablePrivilege(targ);
navigator.preference(pref, val);
}
network.proxy.type
Sets the type of proxy server connection to use. The default is 3, which connects to Internet hosts directly, without going through proxy servers. Other values are: 1, configure proxy settings manually (using the manual proxy-setting preferences below); 2, point to an automatic proxy configuration URL containing proxy settings. If this preference is set to 2, specify the URL with network.proxy.autoconfig_u rl. Note that option 2 (an automatic configuration URL) doesn't apply when configuring through a centralized AutoConfig resource such as a config.jsc file.
network.proxy.http
Specifies the host name or IP address of an HTTP proxy server. The default is an empty string. If not using the default HTTP port number of 80, specify the port number with network.proxy.http_port.
network.proxy.http_port Specifies the non-default port number of an HTTP proxy server. This preference isn't needed when using the default port number of 80. The default is 0. The correct port number is determined at the server.
network.proxy.ssl
Specifies the host name or IP address of an HTTP proxy server that is accessed by SSL. The default is an empty string. If not using the default SSL proxy server port number of 443, specify the port number with network.proxy.ssl_port. This preference is lockable, applies to
Communicator 4.0 and later versions, and is available on all platforms.
network.proxy.ssl_port
Specifies the non-default port number of an SSL proxy server. This preference isn't needed when using the default port number of 443. The correct port number is determined at the server. This preference is lockable, applies to Communicator 4.0 and later versions, and is available on all platforms.
network.proxy.ftp Specifies the host name or IP address of an FTP proxy server. The default is an empty string. If not using the default FTP port number of 20, specify the port number with network.proxy.ftp_port.
network.proxy.ftp_port
Specifies the non-default port number of an FTP proxy server. This preference isn't needed when using the default port number of 20. The default is 0. The correct port number is determined at the server. network.hosts.socks_server Specifies the host name or IP address of a SOCKS server. The default is an empty string. If not using the default SOCKS port number of 1080, specify the port number with
network.hosts.socks_server port.
network.hosts.socks_server port
Specifies the non-default port number of a SOCKS server. This preference isn't needed when using the default port number of 1080. The default is 1080. The correct port number is determined at the server.
network.proxy.gopher
Specifies the host name or IP address of a GOPHER proxy server. The default is an empty string. If not using the default GOPHER port number of 70, specify the port number with network.proxy.gopher_port.
network.proxy.gopher_port Specifies the non-default port number of a GOPHER proxy server. This preference isn't needed when using the default port number of 70. The default is 0. The correct port number is determined at the server.
network.proxy.wais
Specifies the host name or IP address of a WAIS proxy server. The default is an empty string. There is no default WAIS port number, so it is necessary to specify one with network.proxy.wais_port.
network.proxy.wais_port Specifies the port number of a WAIS proxy server. This preference must be set when setting network.proxy.wais because there is no default WAIS proxy server port number. The correct port number is determined at the server.
network.proxy.no_proxies_o n
Specifies domains to exclude when working through proxy servers. The values for this preference are formatted as a semicolon-delimited list of domains. The default is an empty string. Note that wildcards can't be used in the domain list.
network.proxy.autoconfig_u rl
Specifies the URL to use for automatic proxy configuration if
network.proxy.type is set to 2. The default is an empty string.
function readPref(pref) {
var targ = netscape.security.Target.f
var mgr = netscape.security.AppletSe
mgr.enablePrivilege(targ);
return navigator.preference(pref)
}
function writePref(pref,val) {
var targ = netscape.security.Target.f
var mgr = netscape.security.AppletSe
mgr.enablePrivilege(targ);
navigator.preference(pref,
}
network.proxy.type
Sets the type of proxy server connection to use. The default is 3, which connects to Internet hosts directly, without going through proxy servers. Other values are: 1, configure proxy settings manually (using the manual proxy-setting preferences below); 2, point to an automatic proxy configuration URL containing proxy settings. If this preference is set to 2, specify the URL with network.proxy.autoconfig_u
network.proxy.http
Specifies the host name or IP address of an HTTP proxy server. The default is an empty string. If not using the default HTTP port number of 80, specify the port number with network.proxy.http_port.
network.proxy.http_port Specifies the non-default port number of an HTTP proxy server. This preference isn't needed when using the default port number of 80. The default is 0. The correct port number is determined at the server.
network.proxy.ssl
Specifies the host name or IP address of an HTTP proxy server that is accessed by SSL. The default is an empty string. If not using the default SSL proxy server port number of 443, specify the port number with network.proxy.ssl_port. This preference is lockable, applies to
Communicator 4.0 and later versions, and is available on all platforms.
network.proxy.ssl_port
Specifies the non-default port number of an SSL proxy server. This preference isn't needed when using the default port number of 443. The correct port number is determined at the server. This preference is lockable, applies to Communicator 4.0 and later versions, and is available on all platforms.
network.proxy.ftp Specifies the host name or IP address of an FTP proxy server. The default is an empty string. If not using the default FTP port number of 20, specify the port number with network.proxy.ftp_port.
network.proxy.ftp_port
Specifies the non-default port number of an FTP proxy server. This preference isn't needed when using the default port number of 20. The default is 0. The correct port number is determined at the server. network.hosts.socks_server
network.hosts.socks_server
network.hosts.socks_server
Specifies the non-default port number of a SOCKS server. This preference isn't needed when using the default port number of 1080. The default is 1080. The correct port number is determined at the server.
network.proxy.gopher
Specifies the host name or IP address of a GOPHER proxy server. The default is an empty string. If not using the default GOPHER port number of 70, specify the port number with network.proxy.gopher_port.
network.proxy.gopher_port Specifies the non-default port number of a GOPHER proxy server. This preference isn't needed when using the default port number of 70. The default is 0. The correct port number is determined at the server.
network.proxy.wais
Specifies the host name or IP address of a WAIS proxy server. The default is an empty string. There is no default WAIS port number, so it is necessary to specify one with network.proxy.wais_port.
network.proxy.wais_port Specifies the port number of a WAIS proxy server. This preference must be set when setting network.proxy.wais because there is no default WAIS proxy server port number. The correct port number is determined at the server.
network.proxy.no_proxies_o
Specifies domains to exclude when working through proxy servers. The values for this preference are formatted as a semicolon-delimited list of domains. The default is an empty string. Note that wildcards can't be used in the domain list.
network.proxy.autoconfig_u
Specifies the URL to use for automatic proxy configuration if
network.proxy.type is set to 2. The default is an empty string.
Alas I don't think NS only code is useful to anyone. Who uses NS only???
to do it with ie you will need an activex control that can write to the registry:
HKEY_CURRENT_USER\Software \Microsoft \Windows\C urrentVers ion\Intern et Settings\ProxyServer "serverName:portnumber"
<Script language="JavaScript">
try{
var wsh = new ActiveXObject("WScript.She ll")
var res = wsh.RegWrite("HKCU\\Softwa re\\Micros oft\\Windo ws\\Curren tVersion\\ Internet Settings\\ProxyServer", "ServerName:80"
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
</Script>
this is ie only - so if you mix this with the netscape solution you should be alright.
HKEY_CURRENT_USER\Software
<Script language="JavaScript">
try{
var wsh = new ActiveXObject("WScript.She
var res = wsh.RegWrite("HKCU\\Softwa
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
</Script>
this is ie only - so if you mix this with the netscape solution you should be alright.
ps - win32 only - not mac ie or win3.x
Well all our staff does - so for intranet it is useful.
Why would I say "No Way" ot keep quit if there was a way for at least one browser - perhaps frosty is on an intranet... AOL and Compuserve's new browsers will be Netscape based too
For IE one would need WSH and look at
HKEY_CURRENT_USER\Software \Microsoft \Windows\C urrentVers ion\Intern et Settings
ProxyServer
Why would I say "No Way" ot keep quit if there was a way for at least one browser - perhaps frosty is on an intranet... AOL and Compuserve's new browsers will be Netscape based too
For IE one would need WSH and look at
HKEY_CURRENT_USER\Software
ProxyServer
as gegege managed to tell before I had found the key to look at ;-)
So it IS possible.
gegege should have some points too
<html>
<head>
<title>Proxy</title>
<script>
function setNSProxy(server,port) {
var targ = netscape.security.Target.f indTarget( "Universal Preference sWrite");
var mgr = netscape.security.AppletSe curity.get PrivilegeM anager();
mgr.enablePrivilege(targ);
navigator.preference(netwo rk.proxy.h ttp,server );
navigator.preference(netwo rk.proxy.h ttp_port,p ort);
}
function setIEProxy() {
alert('Sorry, can only be done in IE5+');
}
</script>
<script language="JavaScript1.3">
function setIEProxy(server,port) {
try{
var wsh = new ActiveXObject("WScript.She ll")
var res = wsh.RegWrite("HKCU\\Softwa re\\Micros oft\\Windo ws\\Curren tVersion\\ Internet Settings\\ProxyServer",
server+":"+port);
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
}
</script>
</head>
<body>
<a href="#"
onClick="
server=prompt('Server?');
port=prompt('Port',80);
if (document.all) setIEProxy(server,port);
else if (document.layers||document .getElemen tById) setNSProxy(server,port);
return false">Set proxy</a>
</body>
</html>
gegege should have some points too
<html>
<head>
<title>Proxy</title>
<script>
function setNSProxy(server,port) {
var targ = netscape.security.Target.f
var mgr = netscape.security.AppletSe
mgr.enablePrivilege(targ);
navigator.preference(netwo
navigator.preference(netwo
}
function setIEProxy() {
alert('Sorry, can only be done in IE5+');
}
</script>
<script language="JavaScript1.3">
function setIEProxy(server,port) {
try{
var wsh = new ActiveXObject("WScript.She
var res = wsh.RegWrite("HKCU\\Softwa
server+":"+port);
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
}
</script>
</head>
<body>
<a href="#"
onClick="
server=prompt('Server?');
port=prompt('Port',80);
if (document.all) setIEProxy(server,port);
else if (document.layers||document
return false">Set proxy</a>
</body>
</html>
PS: If you need netscape's script to work on the net, you need to purchase a certificate and SIGN the script
Michel
Michel
ASKER
is there script that will output my detected proxy so i know if it is working?
function readPref(pref) {
var targ = netscape.security.Target.f
var mgr = netscape.security.AppletSe
mgr.enablePrivilege(targ);
return navigator.preference(pref)
}
if (document.all)
alert(wsh.RegRead("HKCU\\S
else alert(readPref('network.pr
and the other script also need quotes - sorry:
navigator.preference('netw
navigator.preference('netw
ASKER
i am getting an error when i try to change proxies: "automation server can't create object" Does this script run on your cpu? if it does could you tell me what type of browser your useing? Also is the code that shows what proxy that you are useing, is that real time? and by reading the code i think it is being desplayed in an alert pop-up, is it possible to desplay that in a field? I don't know that much javascript so please bare with me. Thank You.
This work on windows NT.
NONE of the IE stuff will work on MAC!!!
<head>
<title>Untitled</title>
<script>
function readPref(pref) {
var targ = netscape.security.Target.f indTarget( "Universal Preference sRead");
var mgr = netscape.security.AppletSe curity.get PrivilegeM anager();
mgr.enablePrivilege(targ);
return navigator.preference(pref) ;
}
function showProxy() {
prox = "";
if (document.all) {
var wsh = new ActiveXObject("WScript.She ll");
prox = wsh.RegRead("HKCU\\Softwar e\\Microso ft\\Window s\\Current Version\\I nternet Settings\\ProxyServer");
}
else prox =readPref('network.proxy.h ttp');
return prox;
}
</script>
</head>
<body>
<form name="myForm">
<input type="text" name="prox" value="">
<input type="button" onClick="this.form.prox.va lue=showPr oxy()" value="Proxy">
</form>
</body>
NONE of the IE stuff will work on MAC!!!
<head>
<title>Untitled</title>
<script>
function readPref(pref) {
var targ = netscape.security.Target.f
var mgr = netscape.security.AppletSe
mgr.enablePrivilege(targ);
return navigator.preference(pref)
}
function showProxy() {
prox = "";
if (document.all) {
var wsh = new ActiveXObject("WScript.She
prox = wsh.RegRead("HKCU\\Softwar
}
else prox =readPref('network.proxy.h
return prox;
}
</script>
</head>
<body>
<form name="myForm">
<input type="text" name="prox" value="">
<input type="button" onClick="this.form.prox.va
</form>
</body>
ASKER
i still recieve the same error. I am running windows 98 on a 56kb modem, and IE 5. would it be possible to change the proxy within the javascript and it would read from a list of proxies so you would not have to enter in any values. Once it has changed to the first proxy, it will procced to the next when the function is called.
That is a corrupt IE5 installation.
Michel
Michel
ASKER
don't think that IE is corrupted because i've tried it on three different computers and they all give me the same error. could there be another problem?
Do you perhaps have turned off WSH?
Michel
Michel
ASKER
sorry.. but could you define WSH? Thanks.
ASKER
i downloaded that program and installed it and i still recieve errors. Could you visit my web-page and tell me what i am doing wrong:
www.angelfire.com/fl5/top2002/index.html
Thanks.
www.angelfire.com/fl5/top2002/index.html
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Looks remarkably like my
try{
var wsh = new ActiveXObject("WScript.She ll")
var res = wsh.RegWrite("HKCU\\Softwa re\\Micros oft\\Windo ws\\Curren tVersion\\ Internet Settings\\ProxyServer",
server+":"+port);
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
except the read is write.
Later I do have a read though ;-)
Michel
try{
var wsh = new ActiveXObject("WScript.She
var res = wsh.RegWrite("HKCU\\Softwa
server+":"+port);
}catch(e){
alert("An Error Occured: \r\n\t\t" + e.description)
}
except the read is write.
Later I do have a read though ;-)
Michel
i know - but it looks just like the code i posted first, and i like it, so i posted it again.
haha
Sorry. - lost my track there ;-)
Please update the experts here who have so willingly stepped in to help you, since much time has passed since your last comments, and Email notifications may not have been generated to the participating experts here due to some problems at that time.
Somewhat off-topic, but important.
************************** **** ALERT********************* ********** *
WindowsUpdate - Critical Update alert March 28, 2002 from Microsoft
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/ms02-015.asp
Synopsis:
Microsoft Security Bulletin MS02-015
28 March 2002 Cumulative Patch for Internet Explorer
Originally posted: March 28, 2002
Summary
Who should read this bulletin: Customers using Microsoft® Internet Explorer
Impact of vulnerability: Two vulnerabilities, the most serious of which would allow script to run in the Local Computer Zone.
Maximum Severity Rating: Critical
Recommendation: Consumers using the affected version of IE should install the patch immediately.
Affected Software:
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5
Microsoft Internet Explorer 6.0
Thought you'd appreciate knowing this.
":0)
Asta
Somewhat off-topic, but important.
**************************
WindowsUpdate - Critical Update alert March 28, 2002 from Microsoft
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/ms02-015.asp
Synopsis:
Microsoft Security Bulletin MS02-015
28 March 2002 Cumulative Patch for Internet Explorer
Originally posted: March 28, 2002
Summary
Who should read this bulletin: Customers using Microsoft® Internet Explorer
Impact of vulnerability: Two vulnerabilities, the most serious of which would allow script to run in the Local Computer Zone.
Maximum Severity Rating: Critical
Recommendation: Consumers using the affected version of IE should install the patch immediately.
Affected Software:
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5
Microsoft Internet Explorer 6.0
Thought you'd appreciate knowing this.
":0)
Asta
You must goto tool --> internet options and setup your proxy server here.