Solved

Webbrowser control with internet transfer control

Posted on 2004-10-12
4
198 Views
Last Modified: 2012-05-05
Hi,
If I use the internet transfer control to download a webpage, then use the open, write and close methods to insert the html into a webbrowser control, is there a way to also insert the cookies so that when links are clicked on in the webbrowser control the cookies will carry through?

I'm trying to find a way to use the webbrowser control to turn off images for a particular instance of the webbrowser control only and only for certain pages.  I thought this might be a way that I could accomplish it.

Here's another thread that uses a different route to solve the problem.  This method would be using the internet transfer control if it's possible.

The link below is the other, what I believe to be more difficult method.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21153585.html

Please note that changing the registry item for not downloading images isn't possible since my program will be running while browsers are running and we can't have all browsers not downloading images.  Only the webbrowser instance for the webbrowser control.
0
Comment
Question by:jodyglidden
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
Comment Utility
If the Inet control returns any cookies, you can parse them and set them through the WebBrowser as shown below.

Private Sub Command1_Click()
    'Get the current cookies...
    Call MsgBox(WebBrowser1.Document.cookie)
    'Add a cookie...
    WebBrowser1.Document.cookie = "name=1"
    'Get the new cookies to see our addition...
    Call MsgBox(WebBrowser1.Document.cookie)
    'Change the cookie we just added...
    WebBrowser1.Document.cookie = "name=2"
    'Get the new cookies to see our modification...
    Call MsgBox(WebBrowser1.Document.cookie)
End Sub
Private Sub Form_Load()
    WebBrowser1.Navigate "http://www.google.com"
End Sub

There may be an issue with that, however. Since you're writing out the html for certain sites without being at the actual domain, I don't believe the cookie(s) you use will belong to that domain so IE may not send them (I'm not sure though). You can alternatively send the cookies for each link the person goes to as shown below.

Private Sub Form_Load()
    WebBrowser1.Navigate "http://www.google.com"
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    'if no headers were sent.. cancel and send our headers (cookie(s))
    If Headers = vbNullString Then
        Cancel = True
        WebBrowser1.Navigate "www.yahoo.com", , , , "your cookie(s) here"
    End If
End Sub


>> The link below is the other, what I believe to be more difficult method.
More difficult? It seems like "extremely more difficult" instead. :) You may be better off just removing all of the IMG elements from the DOM before they're displayed.
0
 
LVL 17

Expert Comment

by:zzzzzooc
Comment Utility
Seeing as the other question is resolved, you probably don't need this answered anymore. Feel free to post in Community Support asking for this to be PAQ'd and points refunded. I'll agree to that.
0
 
LVL 1

Author Comment

by:jodyglidden
Comment Utility
Ahh, it's fine for me.  Here you go.
0
 
LVL 17

Expert Comment

by:zzzzzooc
Comment Utility
.. didn't need to. Thanks though. :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now