Click here to Skip to main content
15,885,940 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello.

Recently I discovered that my laptop's internet settings for proxy had to be changed depending on where I was. At one place I need to go through a proxy and at another it needs to be open. What I want is to have a button in IE that I can press to change between manual and direct settings. I've found a program that will help me do this easily except there is a popup menu. I'm trying to edit the code so that if the button is pressed it asks itself 'am I in direct, if yes change to manual if no then change to direct'.

Below is the code that I currently have. Any help would be greatly appreciated.

XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
    <meta http-equiv="MSThemeCompatible" content="Yes" />
        <title>ProxyPick</title>
        <script>
        function doSave(){
            if (document.getElementById('rdoDirect').checked == true){
                window.returnValue="direct"; 
            }
            else
            if (document.getElementById('rdoAuto').checked == true){
                window.returnValue="auto"; 
            }
            else
            if (document.getElementById('rdoManual').checked == true){
                window.returnValue=window.dialogArguments; 
            }
            
            window.close();
        }
        function doCancel(){
            window.close();
        }

        function keyDown() {
        var keycode = event.keyCode                            //      String.fromCharCode(event.keyCode)
            if (keycode == 27 || keycode == 75) {
                doCancel();        
                }
            else
                if (keycode == 65){ // "A"
                    document.getElementById('rdoAuto').focus();
                    document.getElementById('rdoAuto').checked = true;
                    document.getElementById('btnSave').disabled=false;
                    }
            else
                if (keycode == 77){ // "M"
                    document.getElementById('rdoManual').focus();
                    document.getElementById('rdoManual').checked = true;
                    document.getElementById('btnSave').disabled=false;
                    }
            else
                if (keycode == 68){ // "D"
                    document.getElementById('rdoDirect').focus();
                    document.getElementById('rdoDirect').checked = true;
                    document.getElementById('btnSave').disabled=false;
                    }
            else
                if (keycode == 13 || keycode == 83){ // Enter or "S"
                    if (document.getElementById('btnSave').disabled == false){
                        doSave();
                    }
                }
      }
    
      document.onkeydown = keyDown
    </script>

    <style>
    .OptionSpan{
        cursor:hand;
        font-size: 12;
    }
    .Note{
        font-size: 12;
    }
    .WeeNote{
        font-size: 10;
        color:    white;
    }
    
    </style>
    </head>
    <body bgcolor="#ECE9D8" style="margin: 4px; font-family: Tahoma, sans-serif; filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr='#C3DAF9',endColorStr='#3280E7'); border:1px solid gray"><!--#BBE8A4 #59734D -->
        <table border="0" height="100%" width="100%" id="tblOptions">
                <tr><td align=left><span class="Note">Please select a proxy configuration:</span></td><td align=right><span class="OptionSpan" onclick="window.close();" title="Cancel"><font color=white><B>X</B></font></td></tr>            
                <tr>
                    <td colspan=2>

            <input type="radio" onclick="btnSave.disabled=false;" value="Direct" id="rdoDirect" name="rgProxy">
            <span class="OptionSpan" onclick="rdoDirect.checked=true;btnSave.disabled=false;"><u>D</u>irect (No Proxy)</span><br>
            
            <input type="radio" onclick="btnSave.disabled=false;" value="Auto" id="rdoAuto" name="rgProxy">
            <span class="OptionSpan" onclick="rdoAuto.checked=true;btnSave.disabled=false;"><u>A</u>uto-detect</span><br>
            
            <script>
            if (window.dialogArguments){
                document.writeln('<input type="radio" onclick="btnSave.disabled=false;" value="' + window.dialogArguments +'" id="rdoManual" name="rgProxy"></font><font size="2">');
                document.writeln('<span class="OptionSpan" onclick="rdoManual.checked=true;btnSave.disabled=false;"><u>M</u>anual (' + window.dialogArguments +')</span><br>');            
            }
            else
            {
                document.writeln('<span class="WeeNote">No manual proxy has been configured in the Internet Control panel.<input type="hidden" id="rdoManual"></span>');
            }
            </script>
                        
            </td>
                </tr>
                <tr><td colspan=2 align=right><button disabled id="btnSave" onclick="doSave();"><u>S</u>ave</button></td></tr>
            </table>
            
    
        <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
</form>
    </body>
</html>
Posted
Updated 23-Feb-10 2:20am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900