|
-
Dec 22nd, 2006, 11:22 AM
#1
Thread Starter
Addicted Member
[2005] Catching ad url's in browser
I've been building an advanced browser, and it's been fun, here's the latest problem i'm suffering from,
When i navigate to a page that uses ad.google.blah, the original url is resolved, then its resolving the ad url as well, is there any way to stop this, maybe by checking the link against the hosts file?
if you need to see code, i'll post it
Redmo
The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp
Please rate the posts that have helped. Makes us feel all warm and fuzzy
-
Dec 22nd, 2006, 11:25 AM
#2
Re: [2005] Catching ad url's in browser
you mean you are trying to prevent embedded content like an ad on a page from displaying?
-
Dec 22nd, 2006, 11:36 AM
#3
Thread Starter
Addicted Member
Re: [2005] Catching ad url's in browser
No, if i wanted to do that, i could remove the content by comparing my url string to the contents of the hosts file, but this is what's happening
url= http://sourceforge.net
resovled url = http://ad.uk.doubleclick.net/adi/N1120.blah blah
is there a way i can stop this from happening?
Redmo
The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp
Please rate the posts that have helped. Makes us feel all warm and fuzzy
-
Dec 22nd, 2006, 11:42 AM
#4
Re: [2005] Catching ad url's in browser
i guess I do need you to post your code. I dont know what you mean by url versus resolved url
-
Dec 22nd, 2006, 11:55 AM
#5
Thread Starter
Addicted Member
Re: [2005] Catching ad url's in browser
Ok, here's what i'm using when go is clicked, there's no checks in there to see what kind of url it is, it just does what its supposed to do
VB Code:
Private Sub tsbGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbGo.Click
'make sure string isn't empty
If tscbAddress.Text = Nothing Then
MsgBox("Please enter an Address", MsgBoxStyle.MsgBoxHelp, "Warning")
Else
'catch about:home
If CBool(String.Compare(tscbAddress.Text.Substring(0, 6), "about:home")) = True Then
Else
'catch about:blank
If CBool(String.Compare(tscbAddress.Text.Substring(0, 6), "about:blank")) = True Then
Else
'finds out if string contains the required http://
If CBool(String.Compare(tscbAddress.Text.Substring(0, 7), "http://")) = True Then
'if it does, then no need to add it
If tscbAddress.Text.Contains("http://") Then
Else
'if it doesn't then we add it here
tscbAddress.Text = "http://" & tscbAddress.Text.ToString()
End If
End If
End If
End If
End If
Try
tmrBrowser.Enabled = True ' Start the animation
wbPKMN.Navigate(tscbAddress.Text) ' Get the URL from the control, and send the WebBrowser to fetch and display it
Catch ex As UriFormatException
nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
With frmException
.lblTitle.Text = "UriFormatException"
.txtDesc.Text = ex.Message & " Error Number: " & Err.Number
.lblSource.Text = ex.Source
.lblTargetMethod.Text = ex.TargetSite.ToString
.ctbSTrace.Text = ex.StackTrace
.ShowDialog(Me)
End With
End Try
End Sub
The code for the keypress event is exactly the same, no point in using different code to do the same thing
Its like the page url is sorted, then its treating the ad's as if the go event has been fired again, therefore runnin this again, and putting the new url in the combobox.
Redmo
The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp
Please rate the posts that have helped. Makes us feel all warm and fuzzy
-
Dec 22nd, 2006, 01:01 PM
#6
Re: [2005] Catching ad url's in browser
I still don't see the problem. The code in this routine should only fire when the button is clicked.
Do you have other code in the webbrowsers navigate complete or document complete events?
-
Dec 22nd, 2006, 03:02 PM
#7
Thread Starter
Addicted Member
Re: [2005] Catching ad url's in browser
This is the code for my WebBrowser_completed
VB Code:
Private Sub wbPKMN_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wbPKMN.Navigated
tscbAddress.Text = e.Url.AbsoluteUri ' add completed url to tscbaddress text.
'Run test to see if the url is already in the collection
If tscbAddress.Items.Contains(e.Url.AbsoluteUri) Then
'if so, then we don't need to add it again
Exit Sub
Else
'add the url to the collection
tscbAddress.Items.Add(e.Url.AbsoluteUri)
End If
End Sub
The only other code that's ran on a regular basis is the selectedIndexChanged
VB Code:
Private Sub tscbAddress_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tscbAddress.SelectedIndexChanged
'Get selected item by casting from object
Dim SelectedUrl As String = CType(tscbAddress.SelectedItem, String)
Try
'If string is empty then exit try
If SelectedUrl Is Nothing Then
Exit Sub
End If
'if string is already in the collection then exit sub
If tscbAddress.Items.Contains(SelectedUrl) = True Then
wbPKMN.Navigate(SelectedUrl)
End If
Catch ex As UriFormatException
nwWriteLogMsg(ex.Message, ".\nwpps2k6err.log", ex.StackTrace, ex.TargetSite.ToString, ex.Source, ex.HelpLink)
With frmException
.lblTitle.Text = "UriFormatException"
.txtDesc.Text = ex.Message & " Error Number: " & Err.Number
.lblSource.Text = ex.Source
.lblTargetMethod.Text = ex.TargetSite.ToString
.ctbSTrace.Text = ex.StackTrace
.ShowDialog(Me)
End With
End Try
End Sub
This is baffling, but i'm sure i'll come up with an answer eventually
Redmo
The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp
Please rate the posts that have helped. Makes us feel all warm and fuzzy
-
Dec 22nd, 2006, 05:23 PM
#8
Addicted Member
Re: [2005] Catching ad url's in browser
I think your problem is not a coding problem. When a web-browser goes to a page that links offsite. It must resolve those links as well. Or in otherwords if the site links to an ad-site for content. That is being resolved after the initial page has been resolved. So what seems to happening is your catching the last resolved URL. Which comes from with in the web-page it self. Just a thought.
-
Dec 22nd, 2006, 06:06 PM
#9
Thread Starter
Addicted Member
Re: [2005] Catching ad url's in browser
Yes, i agree daystar, if i try to catch the offending urls in a trap, i could be tryin to grab 100's of ad urls. I'll figure out a way around it though, give me time 
Redmo
The universal aptitude for ineptitude makes any human accomplishment an incredible miracle -Col. John P. Stapp
Please rate the posts that have helped. Makes us feel all warm and fuzzy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|