I know browsers are a dime a dozen, but in an attempt to teach myself some basic coding I felt that I'd try to make one anyway.
This is my browser, Cream. Though it's just a basic browser with only four controls (back, add tab, remove tab, and go) I want to give it some features found in other browsers, ie java and HTML5.
I've also run into two main errors (one is related to java, I believe). I continually get pop ups that look like this:
Is there any way to disable pop ups like these from appearing, or maybe just to add java?
Next, whenever I click an outside link, it opens in IE instead of in Cream (this only applys to some links; pop ups open in IE as well). Is there a way to make links which would normally open in a new window open in Cream tab?
Lastly, I'd like to be able to hit enter after typing in a URL to go to the page. Is there any easy way to do this?
Thanks guys. Sorry for being such a noob.
You should put this .
WebBrowser1.ScriptErrorsSuppressed = True
or
1) Click (once) on your WebBrowser
2) Open the Properties toolbar
3) Find Script Errors Suppressed > Change to true.
Easy!(:
----------------------------------------------------
If you want pop up blocker.
do this.
1.Double click your Webbrowser
2.In webbrowser Declarations Find >NewWindow<
3.Put this code
e.Cancel = True
MsgBox("Pop-Up Blocked by Exquizyth", MsgBoxStyle.Information, "Pop- Up Blocked")
Then try to go any site and click any pop up ads then it will block.
-----------------------------------------------------
Originally Posted by Exquizyth
1.Double click your Webbrowser
2.In webbrowser Declarations Find >NewWindow<
3.Put this code
Then try to go any site and click any pop up ads then it will block.
-----------------------------------------------------
Yeah, but then it will stop any links that open in a new window opening at all, which would really cripple the experience of the webbrowser.
This is my source code so far.
Code:
Public Class Form1
Dim int As Integer = 0
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
ToolStripTextBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
WebBrowser.ScriptErrorsSupressed = True
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub AddTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub RemoveTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub AddTabToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabToolStripMenuItem.Click
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub
Private Sub RemoveTabToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveTabToolStripMenuItem.Click
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub GoToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToolStripMenuItem.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripTextBox1.Text)
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
End Sub
Private Sub ToolStripTextBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripTextBox1.Click
End Sub
End Class
Where would I drop the 'ScriptErrorSupressed = True' code?
VB says that it's not a valid command, or something like that.
EDIT: I got the errors suppressed by myself.
Does anyone know how I can make pop ups open in Cream instead of in IE?
Also, does anyone know what code I can use to make clicking in the text box highlight all the text inside the box?
@CheeseTea
Do it in the form designer, click on your webbrowser control and go to Properties.
Originally Posted by user782106
@CheeseTea
Do it in the form designer, click on your webbrowser control and go to Properties.