Javascript Links In VB.Net Webbrowser Control
Hey guys,
I have a slight problem with my webbrowser control and opening popups. I can get normal popups to open but when there are javascript commands to open the new windows the control will open a new window but will not load the page, it just stays as a blank webcontrol. So in other words, my code looks for and navigates to the href of the website. But the navigation doesn't go ahead for some reason if the href equals a javascript command line. I do not understand this.
The code that I am using to open popups is:
Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles DefaultWeb.NewWindow
On Error Resume Next
Dim myElement As HtmlElement = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Document.ActiveElement
Dim target As String = myElement.GetAttribute("href")
Dim newInstance As New Form1
newInstance.Show()
CType(newInstance.TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(target)
e.Cancel = True
End Sub
Below is an example of the javascript commands that wont open in my webbrowser:
javascript:var c=window.open('/portal/page/portal/MYPORTAL_GROUP/DET_APPLICATIONS/ADVANCED_SEARCH','search','menu=no,toolbar=no,resizable=yes,scrollbars=yes,status=yes')
If anyone can edit my code so that the webbrowser will open both normal links like it does currently and the javascript links (such as the one above) that would be amazing.