Link to home
Start Free TrialLog in
Avatar of rmichels
rmichels

asked on

WebBrowser Control - Setting Referrer

I am writing a VB program to do some automated web processing.  I need to follow a link on a page, but I can't set it directly as  URL, as the target verifies the referring page.  You must click on the link on the main page for it to work, so the referrer property is set properly.

Is there a way to do this through the WebBrowser Object?
Avatar of TheAnswerMan
TheAnswerMan

WebBrowser1.Navigate "http://www.yahoo.com"
are you saying that the web page you are on needs to be called from a previous page?   Maybe there is a cookie placed on your machine on the previous page.  

When you get the the second page.. copy the url and see if you can use the navigate feature....

If it will not work then you will need to go to the first page.. and after it loads up, then navigate to the second.
Avatar of rmichels

ASKER

TheAnswerMan

The navigate function works fine. I already have that.  That does not answer my question.

The navigate command is the same as if you typed in an address on Internet Explorer.

There is a property on explorer that holds the refering page.  This gets set when you *click* on a link on the page.

Entering an address directly does not set the referring page.

What I'm looking for is a way to follow a link on a page, without using the navigate command for that link.  I use the Navigate method to get to the first page, then from there I need an alternate method to follow a link.

The target web page is checking the referring page, and it must be set or the navigate will get rejected by the target web page
Along for the ride id like to know this too.
Avatar of hes
Not sure how to but according to the documentation, in the following sub the referrer url should be available (therefore changed before the navigate2 event occures)

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)

End Sub

Have used the Cancel and URL variables to change the contents and thus where the webbrowser goes to.
Try and add this to your project and set up a few dummy .htm to referrer to and see what variable contains the URL.
Might give you an idea which one to edit to add what you need.
ASKER CERTIFIED SOLUTION
Avatar of clockwatcher
clockwatcher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial