<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/OnClientBrowserConsoleMessage?action=history&amp;feed=atom</id>
	<title>OnClientBrowserConsoleMessage - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/OnClientBrowserConsoleMessage?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientBrowserConsoleMessage&amp;action=history"/>
	<updated>2026-09-16T23:16:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=OnClientBrowserConsoleMessage&amp;diff=82895&amp;oldid=prev</id>
		<title>Arran Fortuna: Created page with &quot;__NOTOC__ {{Client event}} This event is triggered when a browser outputs a console message, such as a JavaScript error or a message written using console.log().  ==Parameters== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; string message, string source, int line, int level &lt;/syntaxhighlight&gt; *'''message''': the console message. *'''source''': the URL or source identifier where the message originated. *'''line''': the line number where the message originated. *'''leve...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnClientBrowserConsoleMessage&amp;diff=82895&amp;oldid=prev"/>
		<updated>2026-09-16T09:58:04Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ {{Client event}} This event is triggered when a &lt;a href=&quot;/wiki/Element/Browser&quot; title=&quot;Element/Browser&quot;&gt;browser&lt;/a&gt; outputs a console message, such as a JavaScript error or a message written using console.log().  ==Parameters== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; string message, string source, int line, int level &amp;lt;/syntaxhighlight&amp;gt; *&amp;#039;&amp;#039;&amp;#039;message&amp;#039;&amp;#039;&amp;#039;: the console message. *&amp;#039;&amp;#039;&amp;#039;source&amp;#039;&amp;#039;&amp;#039;: the URL or source identifier where the message originated. *&amp;#039;&amp;#039;&amp;#039;line&amp;#039;&amp;#039;&amp;#039;: the line number where the message originated. *&amp;#039;&amp;#039;&amp;#039;leve...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client event}}&lt;br /&gt;
This event is triggered when a [[Element/Browser|browser]] outputs a console message, such as a JavaScript error or a message written using console.log().&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string message, string source, int line, int level&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''message''': the console message.&lt;br /&gt;
*'''source''': the URL or source identifier where the message originated.&lt;br /&gt;
*'''line''': the line number where the message originated.&lt;br /&gt;
*'''level''': the severity level of the message:&lt;br /&gt;
**'''0''': default&lt;br /&gt;
**'''1''': verbose&lt;br /&gt;
**'''2''': info&lt;br /&gt;
**'''3''': warning&lt;br /&gt;
**'''4''': error&lt;br /&gt;
**'''5''': fatal&lt;br /&gt;
**'''6''': disable&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The [[event system#Event source|source]] of this event is the [[Element/Browser|browser]] element that generated the console message.&lt;br /&gt;
&lt;br /&gt;
{{Note|The ''source'' parameter is a string identifying the message's origin. It is separate from the event's ''source'' variable, which refers to the browser element. Use a different parameter name, such as ''messageSource'', to access both.}}&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example loads a local HTML page and prints its browser console messages to the debug output.&lt;br /&gt;
&lt;br /&gt;
'''Client-side Lua:'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local browser = createBrowser(25, 25, true, false)&lt;br /&gt;
&lt;br /&gt;
local logLevels = {&lt;br /&gt;
    [0] = &amp;quot;default&amp;quot;,&lt;br /&gt;
    [1] = &amp;quot;verbose&amp;quot;,&lt;br /&gt;
    [2] = &amp;quot;info&amp;quot;,&lt;br /&gt;
    [3] = &amp;quot;warning&amp;quot;,&lt;br /&gt;
    [4] = &amp;quot;error&amp;quot;,&lt;br /&gt;
    [5] = &amp;quot;fatal&amp;quot;,&lt;br /&gt;
    [6] = &amp;quot;disable&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientBrowserConsoleMessage&amp;quot;, browser, function(message, messageSource, line, level)&lt;br /&gt;
    outputDebugString((&amp;quot;Browser console message: %s (line: %d, source: %s, level: %s)&amp;quot;):format(&lt;br /&gt;
        message, line, messageSource, logLevels[level] or tostring(level)&lt;br /&gt;
    ))&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientBrowserCreated&amp;quot;, browser, function()&lt;br /&gt;
    loadBrowserURL(browser, &amp;quot;http://mta/local/test.html&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''test.html:'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;Browser console example&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;&lt;br /&gt;
        console.log(&amp;quot;Hello from the browser!&amp;quot;);&lt;br /&gt;
        console.warn(&amp;quot;This is a warning.&amp;quot;);&lt;br /&gt;
        console.error(&amp;quot;This is an error.&amp;quot;);&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the HTML file in your resource's '''meta.xml''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;file src=&amp;quot;test.html&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use '''/debugscript 3''' to view the output.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{CEF_events}}&lt;/div&gt;</summary>
		<author><name>Arran Fortuna</name></author>
	</entry>
</feed>