'The long ago I wanted to publish an article about the WebBrowser control of VB and the MSHTML editing CONTROL OF THE Dhtmledit/DhtmlSafe web page
'The WebBrowser control is used as an example to show all the web page editing controls for VB6 development. I wrote a simple tutorial on developing advanced Web pages for VB6.
'More and better network + software programming articles please log onto my website http://www.lshdic.com to find
'Let's talk a little less. Let's start with me and step by step to restore the following complete program to a standard VB6 program.
'Step 1: Start VB6 and add Microsoft Internet Controls to the control toolbox. This is the WebBrowser control.
'Step 2: drag the WebBrowser control icon to the form editor. Drag a textbox Control and eight buttons.
'Step 3: Set The Name Of The WebBrowser control to web, the textbox to text1, and the command to command1, 2, 3, 4, 5, 6, 7, and 8.
'OK. Copy the following code to the original code editor of VB6, and run the program to test ^ o ^.
Dim a As string' defines a judgment variable. To later use this variable for editing/browsing mode switching
Private Sub commandateclick () 'Write: Write the DHTML statement in text1 to the browser
Web. Document. write Text1.Text
End Sub
Private sub command2_click () 'read: msgbox output original file in the browser
Msgbox web. Document. All (0). outerhtml
End sub
Private sub command3_click () ': the browser background becomes red, and the Document Object of the browser is used.
Web. Document. bgcolor = "red"
End sub
Private sub command4_click () 'connection turns yellow: All the hyper-connection colors in the browser turn yellow
For I = 0 to Web. Document. Links. Length-1
Web. Document. Links (I). style. color = "yellow"
Next
End sub
Private sub command5_click () 'uses JS statements to pop up the dialog box
If web. Document. parentwindow. confirm ("do you want to display alert ??? ") Then web. Document. parentwindow. alert" OK"
End Sub
Private Sub Command6_Click () 'Use VBS statement to pop up the dialog box
Web.Document.parentwindow.exe cScript "if msgbox ('do you want to display msgbox ??? ', VbInformation + vbYesNo,' problem ') = vbyes then msgbox' Can '"," vbs"
End Sub
Private Sub Command7_Click () 'browser editing and browsing mode switching freely
If a = "" Then
Web.Document.exe ccommand "editMode"
A = "yes"
Else
Web.Document.exe ccommand "BrowseMode"
A = ""
End If
End Sub
Private Sub Command8_Click () 'uses the window object in the browser to pop up a new window and write the original file in the new window.
Set str1 = web. Document. parentwindow. Open ()
Str1.Document. Open
Str1.Document. write web. Document. All (0). outerHTML
Str1.Document. Close
End Sub
When the Private Sub Form_Load () 'window is started, the browser is not blank, so that the "server not found" page is displayed.
Web. Navigate ""
End Sub
'The use of these controls provided by Microsoft to do nothing, we should make full use of their support for html, css, js, vbs, vml, and dhtml to make a perfect web editor program.
'The network programming technology must be high in this aspect, so that you can fully play the role of VB6. it can be seen that network programming fully extends the functions of VB6, the document Object references the network programming interface.
'The Complete example of the above program source code please visit the http://www.lshdic.com/download/lshdic/vb_editdhtml.zip download