Click here to Skip to main content
15,917,731 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionvb.net desk app using app.config file Pin
dcof1-Jun-18 11:21
dcof1-Jun-18 11:21 
AnswerRe: vb.net desk app using app.config file Pin
Dave Kreskowiak1-Jun-18 13:24
mveDave Kreskowiak1-Jun-18 13:24 
GeneralRe: vb.net desk app using app.config file Pin
dcof4-Jun-18 9:56
dcof4-Jun-18 9:56 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak4-Jun-18 11:13
mveDave Kreskowiak4-Jun-18 11:13 
GeneralRe: vb.net desk app using app.config file Pin
dcof5-Jun-18 4:21
dcof5-Jun-18 4:21 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak5-Jun-18 5:45
mveDave Kreskowiak5-Jun-18 5:45 
GeneralRe: vb.net desk app using app.config file Pin
dcof5-Jun-18 7:48
dcof5-Jun-18 7:48 
GeneralRe: vb.net desk app using app.config file Pin
Dave Kreskowiak5-Jun-18 8:11
mveDave Kreskowiak5-Jun-18 8:11 
QuestionInserting to new table in between two table in ms word from vb.net Pin
Osioghole Clifford28-May-18 13:50
Osioghole Clifford28-May-18 13:50 
QuestionLINQ: How To Make Order By Conditional? Pin
Alan Burkhart26-May-18 16:05
Alan Burkhart26-May-18 16:05 
AnswerRe: LINQ: How To Make Order By Conditional? Pin
Richard MacCutchan27-May-18 1:05
mveRichard MacCutchan27-May-18 1:05 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart29-May-18 14:42
Alan Burkhart29-May-18 14:42 
AnswerRe: LINQ: How To Make Order By Conditional? Pin
Richard Deeming30-May-18 9:58
mveRichard Deeming30-May-18 9:58 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Mycroft Holmes30-May-18 14:27
professionalMycroft Holmes30-May-18 14:27 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Richard Deeming31-May-18 1:15
mveRichard Deeming31-May-18 1:15 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart31-May-18 7:18
Alan Burkhart31-May-18 7:18 
GeneralRe: LINQ: How To Make Order By Conditional? Pin
Alan Burkhart31-May-18 7:33
Alan Burkhart31-May-18 7:33 
QuestionWebBrowser Javascript Error handing via HtmlWindow works in IE8 mode but not in IE10 or Edge. Pin
Jeffrey Cobb26-May-18 15:55
Jeffrey Cobb26-May-18 15:55 
I have an HTML file that I'm loading into a WebBrowser control via .Navigate(myfileURI) which works fine.
In my application I'm trapping Javascript errors in order to handle them myself via the code on this web page:
https://msdn.microsoft.com/en-us/library/system.windows.forms.htmlwindow.error%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

This seems to work fine until I tweak the compatibility mode in the html file. For example, using the meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=8">

or even no such tag at all works fine. However when I use the meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=10">
or
<meta http-equiv="X-UA-Compatible" content="IE=edge">

the code to trap Javascript errors no longer works.

I'd really like to know why?

I'd prefer to use IE10 or edge for access to better Javascript functionality.

Here's the code I used in a simple Visual Basic Form and WebBrowser control as well as a simple "test.html" file below it:
(Note: the "a.args" line in the html file is suppose to deliberately throw an error)

Thanks in advance,
Jeff

Form1.vb
Imports System.Runtime.InteropServices

Public Class Form1

    <ComVisible(True)>
    Public Class JSRequester

        Public this As Form1

        Public Sub log(s As String)
            Debug.Print(s)
        End Sub

        Public Sub send(MFSYS As String)
            Debug.Print("[" + this.Name + "]  INPUT   <" + MFSYS + ">")
            this.WebBrowser1.Document.InvokeScript("eval", New Object() {"alert('Hello Script!');"})
        End Sub

        Public Sub New(frmSender As Form1)
            this = frmSender
        End Sub
    End Class

    <ComVisible(False)>
    Public bMouseDown As Boolean = False
    Public bFormActivated As Boolean = False
    Public WithEvents ScriptWindow As HtmlWindow

    Private Sub nav(uriFile As Uri)
        Debug.Print("STARTED")
        WebBrowser1.Navigate(uriFile)
    End Sub

    Private Sub SuppressScriptErrors()
        If (WebBrowser1.Document IsNot Nothing) Then
            ScriptWindow = WebBrowser1.Document.Window
        End If
    End Sub

    Private Sub ScriptWindow_Error(ByVal sender As Object, ByVal e As HtmlElementErrorEventArgs) Handles ScriptWindow.Error
        MessageBox.Show("Suppressed error!")
        e.Handled = True
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        '*** Change this to your path ***
        Dim strAppPath As String = "D:\dev\vbnet\SuppressJavascriptErrors"
        Dim uriFile As New Uri("file:///" + strAppPath + "\test.html")
        Me.WebBrowser1.ObjectForScripting = New JSRequester(Me)
        nav(uriFile)
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        Debug.Print("COMPLETED")
    End Sub

    Private Sub WebBrowser1_Navigated(sender As Object, e As WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
        Debug.Print("NAVIGATED")
        SuppressScriptErrors()

    End Sub
End Class


test.html
<!DOCTYPE html>
<html>
<head profile="http://gmpg.org/xfn/11">
	<meta http-equiv="X-UA-Compatible" content="IE=8"> <!-- change this to "10" or "edge" it FAILS -->
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
	<META HTTP-EQUIV="EXPIRES" CONTENT="0">
	<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>YouTube Viewer</title>
	<link rel="stylesheet" type="text/css" href="ytv.css">
</head>
	<body onload="init();">
		<script type="text/javascript">
			function testme() {
				a.args = "hello" // deliberately throw error
				return;
			}

			function init() {
				window.external.log(">>>HELLO DEBUG...");
				window.external.send(">>>HELLO SENDER...");
				testme();
				document.write("<h1>Hello World!</h1>");
			}
		</script>
	</body>
</html>

QuestionOutlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software24-May-18 18:41
HPS-Software24-May-18 18:41 
AnswerRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
Richard Deeming25-May-18 2:35
mveRichard Deeming25-May-18 2:35 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software26-May-18 20:51
HPS-Software26-May-18 20:51 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
Eddy Vluggen26-May-18 23:05
professionalEddy Vluggen26-May-18 23:05 
GeneralRe: Outlook Mail Drag Drop into Textbox of a Win Form Pin
HPS-Software27-May-18 18:14
HPS-Software27-May-18 18:14 
QuestionSave in datagriedview in application Pin
Member 1361197220-May-18 8:13
Member 1361197220-May-18 8:13 
AnswerRe: Save in datagriedview in application Pin
Dave Kreskowiak20-May-18 11:40
mveDave Kreskowiak20-May-18 11:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.