Visual Basic 6 Black Book:Visual Basic And The Internet: Web Browsing, Email, HTTP, FTP, And DHTML
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Listing 21.1 browser.frm version 1
VERSION 6.00
Object = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}#1.1#0"; "SHDOCVW.DLL"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 7560
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 7560
StartUpPosition = 3 'Windows Default
Begin ComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 630
Left = 0
TabIndex = 1
Top = 0
Width = 7560
_ExtentX = 13335
_ExtentY = 1111
ButtonWidth = 1164
ButtonHeight = 953
Appearance = 1
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 6
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "Back"
Key = "Back"
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "Next"
Key = "Next"
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "Home"
Key = "Home"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "Stop"
Key = "Stop"
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "Refresh"
Key = "Refresh"
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 4
Object.Width = 100
EndProperty
EndProperty
Begin VB.ComboBox Combo1
Height = 315
Left = 3480
TabIndex = 2
Top = 120
Width = 3975
End
End
Begin SHDocVwCtl.WebBrowser WebBrowser1
Height = 2295
Left = 120
TabIndex = 0
Top = 840
Width = 7335
ExtentX = 12938
ExtentY = 4048
ViewMode = 1
Offline = 0
Silent = 0
RegisterAsBrowser= 0
RegisterAsDropTarget= 1
AutoArrange = -1 'True
NoClientEdge = 0 'False
AlignLeft = 0 'False
ViewID = "{0057D0E0-3573-11CF-AE69-08002B2E1262}"
Location = ""
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
WebBrowser1.Navigate "www.microsoft.com"
Combo1.Text = "www.microsoft.com"
Combo1.AddItem Combo1.Text
End Sub
Private Sub WebBrowser1_DownloadComplete()
Me.Caption = WebBrowser1.LocationName
Combo1.AddItem WebBrowser1.LocationURL, 0
End Sub
Private Sub Combo1_Click()
WebBrowser1.Navigate Combo1.Text
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Combo1_Click
End If
End Sub
Adding Back And Forward Buttons To A Web Browser
Now that weve set up a Web browser in which the user can navigate by typing URLs into the combo box (see the previous topic), well enable the Back and Forward buttons in the browser.
Thats easier than you might expectyou just use the browsers GoBack or GoForward methods. We do that like this, where we determine which button in the toolbar has been clicked by checking the keys weve added to those buttons:
Private Sub Toolbar1_ButtonClick(ByVal Button As Button)
Select Case Button.Key
Case "Back"
WebBrowser1.GoBack
Case "Forward"
WebBrowser1.GoForward
End Select
End Sub
And thats all there is to itnow the user can navigate forwards and backwards in the browsers history. Weve added Back and Forward buttons now, but the user also expects Refresh, Home, and Stop buttons in Web browsers, and well add those buttons next.
Adding Refresh, Home, And Stop Buttons To A Web Browser
In the previous few topics, weve set up a Web browser complete with combo box to let the user enter and select URLs, as well as a Back and Forward button to let the user navigate through the browsers history. However, we still have a few more buttons to implement: the Refresh, Home, and Stop buttons.
We can implement those buttons with the Web browser controls Refresh, GoHome, and Stop methods. Weve given the Refresh, Home, and Stop buttons the keys Refresh, Home, and Stop, so we just call the appropriate Web browser method when the matching button is clicked (note that if the user clicks the Stop button, we also update the current URL as displayed in the browsers title bar using the Web browsers LocationName property):
Private Sub Toolbar1_ButtonClick(ByVal Button As Button)
Select Case Button.Key
Case "Back"
WebBrowser1.GoBack
Case "Forward"
WebBrowser1.GoForward
Case "Refresh"
WebBrowser1.Refresh
Case "Home"
WebBrowser1.GoHome
Case "Stop"
WebBrowser1.Stop
Me.Caption = WebBrowser1.LocationName
End Select
End Sub
Now the user can use the new buttons, Refresh, Home, and Stop. The code for the finished Web browser is located in the browser folder on this books accompanying CD-ROM.
TIP: You used to be able to specify the browsers search page in the Internet Explorer, but as of Internet Explorer version 4, you are taken to a page of Microsofts choosing. If you still want to implement a Search button, however, just use the WebBrowser controls GoSearch method.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
Nuestro Circulo 705 GIBRALTAR 2016 27 de febrero de 2016www mediweb pl sex wyswietl vad php id=702702 (2)702,40,artykulNuestro Circulo 702 PROHIBIR EL AJEDREZ Por Leontxo García 6 de febrero de 2016705 full702 awięcej podobnych podstron