Page not loading e.cancel = true
Why would this not work? I get the new window to open yet it does not load. When I right click to veiw source it is empty.
It will load without this in IE.
The Address looks normal
http://v.XXX.com/XXX/nVia7OaEHd7UYlv4.html
Code:
Private Sub WebBrowser2_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser2.NewWindow
Dim myElement As HtmlElement = WebBrowser1.Document.ActiveElement
Dim target As String = myElement.GetAttribute("href")
Dim newInstance As New Form5
newInstance.Show()
newInstance.WebBrowser1.Navigate(target)
'cancel opening IE window
e.Cancel = True
End Sub
Thank You
Re: Page not loading e.cancel = true
check your target... make sure the url is correct.
-tg
Re: Page not loading e.cancel = true
This is how I have handled the NewWindow. Set a reference to Microsoft Internet Controls on the COM tab of the Add Reference Dialog and use code similar to this:
Code:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("http://www.vbforums.com")
Dim activeXBrowser As SHDocVw.WebBrowser = CType(WebBrowser1.ActiveXInstance, SHDocVw.WebBrowser)
AddHandler activeXBrowser.NewWindow3, AddressOf axBrowserNewWindow3
End Sub
Private Sub axBrowserNewWindow3(ByRef ppDisp As Object, ByRef cancel As Boolean, dwflags As UInteger, bstrUrlContent As String, bstrUrl As String)
Dim frm As New Form1
frm.Show()
frm.WebBrowser1.Navigate(bstrUrl)
cancel = True
End Sub
Private Sub WebBrowser1_NewWindow(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
e.Cancel = True
End Sub
Re: Page not loading e.cancel = true
Joacim
That worked I get this error though. Can I put it in try command to control that? Or how? I do not have any private declarations also on Netframe 4.
Quote:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Quote:
Private Sub Form14_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebBrowser2.Navigate("http://api.v.xxxx.com/xxxxx/sports/live.html")
Dim activeXBrowser As SHDocVw.WebBrowser = CType(WebBrowser2.ActiveXInstance, SHDocVw.WebBrowser)
AddHandler activeXBrowser.NewWindow3, AddressOf axBrowserNewWindow3
End Sub
Private Sub axBrowserNewWindow3(ByRef ppDisp As Object, ByRef cancel As Boolean, ByVal dwflags As UInteger, ByVal bstrUrlContent As String, ByVal bstrUrl As String)
Dim frm As New Form5
frm.Show()
frm.WebBrowser1.Navigate(bstrUrl)
cancel = True
End Sub
Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow
e.Cancel = True
End Sub
End Class