locked
Customising your Web Browser RRS feed

  • Question

  • How do you create Backward and Forward buttons in your own internet browser?

    Thursday, January 10, 2008 8:33 PM

Answers

  • This would be one way to implement foreward and backward buttons for a browser.  Of course the design of your browser is going to have a lot to do with how you implement these buttons.

     

    Code Block

    Public Class Form1


    Private Sub btnBackward_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) _
        Handles btnBackward.Click


        If iWebPageIndex > 0 Then
            iWebPageIndex -= 1
            lstWebPages.Item(iWebPageIndex).DisplayThisPage()
        Else
            MsgBox("Already at first page!")
        End If
    End Sub


    Private Sub btnForeward_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) _
        Handles btnForeward.Click


        If iWebPageIndex < lstWebPages.Count - 1 Then
            iWebPageIndex += 1
            lstWebPages.Item(iWebPageIndex).DisplayThisPage()
        Else
            MsgBox("Already at last page!")
        End If
    End Sub
    End Class


    Public Module Sample


    Public lstWebPages As List(Of WebPage)
    Public iWebPageIndex As Integer = -1


    End Module


    Public Class WebPage
        'Store all of your web page
        'functions info here!!!


    Public Sub New()
        'When a new web page is created
        'get rid of all foreward pages
        'and add this one to the list.


        iWebPageIndex += 1
        Do While iWebPageIndex < lstWebPages.Count
            lstWebPages.RemoveAt(iWebPageIndex)
        Loop


        lstWebPages.Add(Me)


    End Sub


    Public Sub DisplayThisPage()
        'Add your code to display a
        'web page here!!!
    End Sub


    End Class

     

     

    Thursday, January 10, 2008 9:43 PM

All replies

  • This would be one way to implement foreward and backward buttons for a browser.  Of course the design of your browser is going to have a lot to do with how you implement these buttons.

     

    Code Block

    Public Class Form1


    Private Sub btnBackward_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) _
        Handles btnBackward.Click


        If iWebPageIndex > 0 Then
            iWebPageIndex -= 1
            lstWebPages.Item(iWebPageIndex).DisplayThisPage()
        Else
            MsgBox("Already at first page!")
        End If
    End Sub


    Private Sub btnForeward_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) _
        Handles btnForeward.Click


        If iWebPageIndex < lstWebPages.Count - 1 Then
            iWebPageIndex += 1
            lstWebPages.Item(iWebPageIndex).DisplayThisPage()
        Else
            MsgBox("Already at last page!")
        End If
    End Sub
    End Class


    Public Module Sample


    Public lstWebPages As List(Of WebPage)
    Public iWebPageIndex As Integer = -1


    End Module


    Public Class WebPage
        'Store all of your web page
        'functions info here!!!


    Public Sub New()
        'When a new web page is created
        'get rid of all foreward pages
        'and add this one to the list.


        iWebPageIndex += 1
        Do While iWebPageIndex < lstWebPages.Count
            lstWebPages.RemoveAt(iWebPageIndex)
        Loop


        lstWebPages.Add(Me)


    End Sub


    Public Sub DisplayThisPage()
        'Add your code to display a
        'web page here!!!
    End Sub


    End Class

     

     

    Thursday, January 10, 2008 9:43 PM


  • code for back button is

    webbrowser1.goback

    code for forward button is

    webbrowser1.goback

    REPLACE GO AND BACK WITH webroser name
    Tuesday, January 22, 2008 11:18 PM