Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Webbrowser control with internet transfer control

Posted on 2004-10-12
4
Medium Priority
?
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 1500 total points
ID: 12294928
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
ID: 12307728
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
ID: 12307741
Ahh, it's fine for me.  Here you go.
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 12307800
.. didn't need to. Thanks though. :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

636 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