idcvbteam
asked on
WebBrowser, Prevent Telnet
Useing the WebBrowser, how do you prevent it
from opening links like Telnet://Host.com
from opening links like Telnet://Host.com
ASKER
Sorry,
I really Intend on blocking it thre the Web Browser
Control. I do not wish to modify these settings as I hate
it when other apps do this to my system.
I simply would like to cancel any url that starts with
telnet://
So far, I can read it, just do not know how
to cancel it.
Following is code that can be placed in the click event for the text box that houses the URL. The code that tests for Telnet should be here, as well as anywhere else you are telling the Internet Browser Control to Navigate
(i.e. brwWebBrowser.Navigate). It's a simple check of the string, to make sure that Telnet is not present). You can modify the actual source to be as picky as you want. You can also expand it so that users don't get unwanted PROTOCOL errors. I.e. if they type asdf:// or whatever. This works just fine, and displays a message to the user that Telnet is not allowed. Any of this can be changed to suit your purposes. It's simple easy and quick though, and catches the problem before it starts :)
decypher
-------------------------- ----------
Private Sub cboAddress_Click()
If mbDontNavigateNow Then Exit Sub
timTimer.Enabled = True
If UCase$(Left$(cboAddress.Te xt, 6)) = "TELNET" Then
Msg = "Telnet Not Allowed"
Style = vbOKOnly
Title = "Sorry"
Response = MsgBox(Msg, Style, Title)
Else
brwWebBrowser.Navigate cboAddress.Text
End If
End Sub
(i.e. brwWebBrowser.Navigate). It's a simple check of the string, to make sure that Telnet is not present). You can modify the actual source to be as picky as you want. You can also expand it so that users don't get unwanted PROTOCOL errors. I.e. if they type asdf:// or whatever. This works just fine, and displays a message to the user that Telnet is not allowed. Any of this can be changed to suit your purposes. It's simple easy and quick though, and catches the problem before it starts :)
decypher
--------------------------
Private Sub cboAddress_Click()
If mbDontNavigateNow Then Exit Sub
timTimer.Enabled = True
If UCase$(Left$(cboAddress.Te
Msg = "Telnet Not Allowed"
Style = vbOKOnly
Title = "Sorry"
Response = MsgBox(Msg, Style, Title)
Else
brwWebBrowser.Navigate cboAddress.Text
End If
End Sub
ASKER
Sorry, but I need to prevent the WebBrowser from launching Telnet, not the user.
You see, the user can still click on Links that launch Telnet.
I want to stop that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shorter code to do the same thing, I just removed the calls to HTTP and FTP. However, you can add functionality to your program by adding FTP or HTTP, or whatever valid URL's you want to this procedure, then on the last ELSE, Cancel it there, and have a message telling your users that they entered an Invalid URL, or something of the sort. That way you are telling them a nice message, not the control sending back a nasty one.
'Checks to see what type of URL they are going to
If UCase$(Left$(URL, 6)) = "TELNET" Then
'Lets them know Telnet Not Allowed
Response = MsgBox("Telnet Not Allowed", vbOKOnly, "Sorry")
If Response = vbOK Then
'Cancels navigation to Telnet session
Cancel = True
End If
Else
Exit Sub
End If
'Checks to see what type of URL they are going to
If UCase$(Left$(URL, 6)) = "TELNET" Then
'Lets them know Telnet Not Allowed
Response = MsgBox("Telnet Not Allowed", vbOKOnly, "Sorry")
If Response = vbOK Then
'Cancels navigation to Telnet session
Cancel = True
End If
Else
Exit Sub
End If
ASKER
Bingo!
HKEY_CLASSES_ROOT/telnet/s
Good Luck
decYPH3r
P.S. Registry editing can be dangerous. Don't blame me if it messes up. I take no responsibility. (read microsofts speal) :)