|
-
Nov 22nd, 2012, 05:58 AM
#1
Thread Starter
Addicted Member
[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
-
Nov 22nd, 2012, 08:14 AM
#2
Re: Difficult webbrowser question :)
Is this even after clearing your cache?
-
Nov 22nd, 2012, 08:27 AM
#3
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.
-
Nov 22nd, 2012, 09:01 AM
#4
Thread Starter
Addicted Member
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.
-
Nov 22nd, 2012, 09:05 AM
#5
Re: Difficult webbrowser question :)
Ah......look at your extension assignments in windows explorer....see what .pdf are linked to.
-
Nov 22nd, 2012, 09:08 AM
#6
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
-
Nov 22nd, 2012, 09:16 AM
#7
Thread Starter
Addicted Member
Re: Difficult webbrowser question :)
The *.pdf are linked to Adobe Reader 9.4
-
Nov 22nd, 2012, 09:20 AM
#8
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...
Last edited by Bonnie West; Nov 22nd, 2012 at 09:32 AM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Nov 22nd, 2012, 09:24 AM
#9
Re: Difficult webbrowser question :)
Adobe Reader probably has a setting that tells IE not to open PDF links in a new browser.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Nov 22nd, 2012, 10:05 AM
#10
Thread Starter
Addicted Member
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....
-
Nov 22nd, 2012, 10:21 AM
#11
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...
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Nov 22nd, 2012, 10:24 AM
#12
Thread Starter
Addicted Member
Re: Difficult webbrowser question :)
Thanks for your efforts Bonnie, much apppreciated.
-
Nov 22nd, 2012, 05:40 PM
#13
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.
-
Nov 23rd, 2012, 04:08 AM
#14
Thread Starter
Addicted Member
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.
-
Nov 23rd, 2012, 01:50 PM
#15
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Nov 23rd, 2012, 05:57 PM
#16
Thread Starter
Addicted Member
Re: Difficult webbrowser question :)
Wow, Thanks jmsrickland, It works a treat now. Exactly what i wanted.
Ultimate respect to you!
Cheers
-
Jan 8th, 2013, 11:45 AM
#17
Junior Member
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
-
Jan 9th, 2013, 11:55 AM
#18
Banned
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
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
|