[RESOLVED] Difficult webbrowser question :)
Dear all,
i have been googling this issue for some time but have drawn a blank.
I have a webrowser on my form which works well. Web pages change within the webbrowser. However, there are instances where i click a link and rather than opening up within the webbrowser,the page opens up with internet explorer 9. How can i disable this so that all links are opened up within the webrowser.
Any help would be greatly appreciated :)
Sparkash
Re: Difficult webbrowser question :)
Is this even after clearing your cache?
Re: Difficult webbrowser question :)
There IS a small possibility that those pages you are trying to open are configured for Internet Explorer only (or IE and possibly some others), so if it gets a request from an unrecognized webbrowser, it may open in its default.
Re: Difficult webbrowser question :)
Hi SamOscarBrown, Thanks for your reply.
Yes, i have cleared the cache. On the webpage i am accessing, all links to other internal webpages are viewed within the webbrowser. However, the links that open up in IE are PDF documents.
Re: Difficult webbrowser question :)
Ah......look at your extension assignments in windows explorer....see what .pdf are linked to.
Re: Difficult webbrowser question :)
In Win7, go to: Control Panel\Programs\Default Programs\Set Associations
In XP, go to: Windows Explorer, Tools, Folder Options, File Types Tab
Re: Difficult webbrowser question :)
The *.pdf are linked to Adobe Reader 9.4
Re: Difficult webbrowser question :)
Try this:
Code:
'Click WebBrowser1's NewWindow2 event from the two comboboxes in the IDE
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Select Case MsgBox("[Yes] Open link in a new window" & vbNewLine & _
"[No] Open link in Internet Explorer", _
vbQuestion Or vbYesNoCancel Or vbDefaultButton3)
Case vbYes: With New Form1 'Change to your Form's name
Set ppDisp = .WebBrowser1.Object
.Show
End With
Case vbNo: 'Link will open in Internet Explorer
Case vbCancel: Cancel = True
End Select
End Sub
Still can't get it to open in the same browser though...
Re: Difficult webbrowser question :)
Adobe Reader probably has a setting that tells IE not to open PDF links in a new browser.
Re: Difficult webbrowser question :)
Hi Bonnie West, yes i have found a setting within preferences with Adobe Reader which tells it not to open a PDF using Internet Explorer.However, instead the PDF is downloaded and opened up within the PDF reader, rather than opening up in the Browser control. Hmmmm....
Re: Difficult webbrowser question :)
I haven't been able to force the WebBrowser control to open all links within the same window, the best I could come up was post #8. Sorry...
Re: Difficult webbrowser question :)
Thanks for your efforts Bonnie, much apppreciated.
Re: Difficult webbrowser question :)
Can't you opened the .pdf when downloaded with te webbrowser
Ex
WebBrowser1.Navigate "C:\MyPDF.pdf"
Not testes but i would think you could save all downloads to a temp and then delete when app is closed.
Re: Difficult webbrowser question :)
Hi Max187Boucher,
This is the crux of my problem. The PDF will not open up within the WEbbrowser1 control. Otherwise i could then download it to a local file.
Re: Difficult webbrowser question :)
To click on a link in WebBrowser1 and have that link open up in WebBrowser1 you might try this:
Code:
Private WithEvents NewWebBrowserWindowHandler As SHDocVwCtl.WebBrowser_V1
Private Sub Command1_Click()
WebBrowser1.Navigate "www.vbforums.com"
End Sub
Private Sub Form_Load()
Set NewWebBrowserWindowHandler = WebBrowser1.Object 'Your webrowser control comes here..
End Sub
Private Sub NewWebBrowserWindowHandler_NewWindow(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Processed As Boolean)
'
' You could also have WebBrowser2 and use
' that one for the links
'
WebBrowser1.Navigate URL
Processed = True 'Tell the control, your code have processed the event, there's no need to open the new window
End Sub
Re: Difficult webbrowser question :)
Wow, Thanks jmsrickland, It works a treat now. Exactly what i wanted.
Ultimate respect to you!
Cheers :)
Re: [RESOLVED] Difficult webbrowser question :)
Hi,
Just wrestling with the same problem
did a search.. and this code works perfectly
Thanks from me also to jmsrickland
Re: [RESOLVED] Difficult webbrowser question :)
Code:
Private Sub Form_Load()
WebBrowser1.Silent = True
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
WebBrowser1.Silent = True
End Sub
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Cancel = True
End Sub