none
I am making a web browser in C# I am stuck and need help. RRS feed

  • Question

  • I have all the normal stuff done like URL Bar, back, forward, refresh, and web browser. I need to know how to make a button that will go to another form and display there web history.
    Sunday, December 8, 2019 12:13 AM

All replies

  • Why are you trying to reinvent the wheel?
    Sunday, December 8, 2019 1:24 AM
  • I am sorry? The wheel?
    Sunday, December 8, 2019 1:40 AM
  • I am sorry? The wheel?
    WebBrowser Class
    Sunday, December 8, 2019 2:23 AM
  • I am sorry? The wheel?

    How long have wheels been in use in the world?  How long have browsers been in usage in the world? How many browses are there in the world that are free and can be downloaded and installed on a computer in the world?  

    You making a browser and don't know how to secure a browser from attacks from dubious sites with bad intentions on a drive-by and with your browser's inability to protect the O/S can only lead to what?  

    Can we say 'compromised'? Can we say 'hacked'?

    So why try to reinvent the browse yourself, the wheel?

    Sunday, December 8, 2019 6:12 AM
  • Maybe intercept the DocumentCompleted event, where you will receive the address of Web page. From other members of WebBrowser you can also extract the title. Then you can keep this information in a list and even save to disk. Use this list in your History form.

    Sunday, December 8, 2019 9:36 AM
  • Hi Devin,

    Thank you for posting here.

    For your question, you want to make a button that will go to another form and display the web history.

    You can use WebBrowser1_Navigated () to record the web page URL and title and store them in the database.

    When you open the second form, you can read the data from the database and display it.

           private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
            {
               // Store data in the database
           } 
    

    Hope this could be helpful.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 9, 2019 7:56 AM
  • Hello,

    Something along these lines

    https://stackoverflow.com/questions/14148767/access-history-and-other-stuff-from-browser-control

    Stack<Uri> history= new Stack<Uri>();
    Uri current = null; 
    private void WebBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
    {
        Uri previous = null;           
        if (history.Count > 0)
            previous = history.Peek();
    
        // This assumption is NOT always right. 
        // if the page had a forward reference that creates a loop (e.g. A->B->A ), 
        // we would not detect it, we assume it is an A -> B -> back () 
        if (e.Uri == previous)
        {
            history.Pop();                     
        }
        else
        {
            if (current != null)
                history.Push(current);                          
        }
        current = e.Uri; 
    }

    And

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
        base.OnBackKeyPress(e);
    
        if (!isPerformingCloseOperation) 
        {
            if (history.Count > 0)
            {                        
                Uri destination = history.Peek();
                webBrowser.Navigate(destination);
                // What about using script and going history.back? 
                // you can do it, but 
                // I rather use that to keep ‘track’ consistently with our stack 
                e.Cancel = true;
            }
        } 
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, December 9, 2019 10:47 PM
    Moderator