Post by enzoko on Apr 25, 2016 13:03:40 GMT 10
Hi, How to show separate window in other tab when you click on a link ? Like WebExpress when you click on a link, he open it in a new tab. I search on google and i tried the given solutions but my web browser always show the tab in a separate window. Thanks for helping and sorry for my english, i speak french .
|
|
Post by Nathan Lecompte on Apr 25, 2016 15:24:25 GMT 10
Yeah you need to use the ILifeSpan Handler. 1. Put this right after your "Public Class Blablabla": Implements ILifeSpanHandler 2. Put this code wherever you want, just fill them with whatever you'd want the browser to do when a window is created: Public Function OnBeforePopup(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, targetUrl As String, targetFrameName As String, targetDisposition As WindowOpenDisposition, userGesture As Boolean, windowInfo As IWindowInfo, ByRef noJavascriptAccess As Boolean, ByRef newBrowser As IWebBrowser) As Boolean Implements ILifeSpanHandler.OnBeforePopup 'Main.newlinktabURL = targetUrl 'Main.CreateLinkTab() MsgBox("New link clicked: " + targetUrl) Return True End Function
Public Sub OnAfterCreated(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnAfterCreated MsgBox("New link clicked AfterCreated") End Sub
Public Function DoClose(browserControl As IWebBrowser, browser As IBrowser) As Boolean Implements ILifeSpanHandler.DoClose Return True End Function
Public Sub OnBeforeClose(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnBeforeClose MsgBox("New link clicked BeforeClose") End Sub
Hope this helps!
|
|
Post by enzoko on Apr 26, 2016 13:56:45 GMT 10
I tried this code but the window always opens. Here is the code :
#Region "Popups Window" Public Function DoClose(browserControl As IWebBrowser, browser As IBrowser) As Boolean Implements ILifeSpanHandler.DoClose Return True End Function
Public Sub OnAfterCreated(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnAfterCreated MsgBox("New Link After created") End Sub
Public Sub OnBeforeClose(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnBeforeClose MsgBox("Before Close link") End Sub
Public Function OnBeforePopup(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, targetUrl As String, targetFrameName As String, targetDisposition As WindowOpenDisposition, userGesture As Boolean, windowInfo As IWindowInfo, ByRef noJavascriptAccess As Boolean, ByRef newBrowser As IWebBrowser) As Boolean Implements ILifeSpanHandler.OnBeforePopup MsgBox("Link = " & targetUrl) Return True End Function #End Region
and i wrote that at the top of the code
Public Class Tab Implements ILifeSpanHandler
|
|
Post by Nathan Lecompte on Apr 26, 2016 14:36:11 GMT 10
Hmm...what version of CEFSharp are you using?
|
|
Post by enzoko on Apr 27, 2016 7:41:35 GMT 10
I am using CEFSharp 43.0.0.0 I downloaded CEFSharp 49.0.0.0 and I try again , but it still does not work. I have the same problem as with the implementation of download ( IDownloadHandler )
Last Edit: Apr 27, 2016 14:10:00 GMT 10 by enzoko
|
|
Post by Nathan Lecompte on Apr 27, 2016 15:15:54 GMT 10
Well I was planning on using CEFSharp for Moondrop, but recently changed to something else (not gonna say it yet, just in case); there were quite a few stability issues with CEFSharp, including: -Flash issues (however Flash use is slowly fading out due to security issues) -Fullscreen issues (that was a serious pain, there is a fix for the older version of CEFSharp I think, but even then; still quite buggy) -Download issues (sometimes it wouldn't trigger the download function at all) -And finally, the LifeSpan issues....which I struggled with for a while, thinking it was something else causing it not to work; but then it came to no surprise that it'd be an issue with CEFSharp.
I don't think CEFSharp for VB.NET is all too stable and in my opinion, I would discourage the use of it. If you're really really really wanting to use CEFSharp; then you're best option (in terms of similar function to using it in VB.NET) would be by using it in a C# application; still not completely stable; but a lot better than the VB.NET one.
|
|
Post by enzoko on Apr 27, 2016 15:41:21 GMT 10
Thanks for the advice. But I still find it weird because WebExpress uses VB.Net and implementation of LifeSpan works
|
|
Post by Nathan Lecompte on Apr 27, 2016 16:21:53 GMT 10
Maybe try asking Sential (the creator of WebExpress) to see how he managed to make it work
|
|
Post by enzoko on Apr 30, 2016 6:51:00 GMT 10
I finally managed to implement them. I just made a mistake . Now it works. Thanks for the help. Here's what to write :
Public Class 'Name of your Class Implements ILifeSpanHandler
webbrowser.LifeSpanHandler = Me 'I had forgotten this
Public Function DoClose(browserControl As IWebBrowser, browser As IBrowser) As Boolean Implements ILifeSpanHandler.DoClose Return True End Function Public Sub OnAfterCreated(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnAfterCreated MsgBox("New Link After created") End Sub Public Sub OnBeforeClose(browserControl As IWebBrowser, browser As IBrowser) Implements ILifeSpanHandler.OnBeforeClose MsgBox("Before Close link") End Sub Public Function OnBeforePopup(browserControl As IWebBrowser, browser As IBrowser, frame As IFrame, targetUrl As String, targetFrameName As String, targetDisposition As WindowOpenDisposition, userGesture As Boolean, windowInfo As IWindowInfo, ByRef noJavascriptAccess As Boolean, ByRef newBrowser As IWebBrowser) As Boolean Implements ILifeSpanHandler.OnBeforePopup MsgBox("Link = " & targetUrl) Return True End Function
Last Edit: Apr 30, 2016 6:54:22 GMT 10 by enzoko
|
|