Inline event handlers lost their arguments

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
User avatar
seadragon
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2021-06-18, 04:39

Inline event handlers lost their arguments

Post by seadragon » 2026-07-07, 11:01

Operating system: Windows 10 latest
Browser version: Pale Moon 34.3.1
32-bit or 64-bit browser?: 64-bit

The problem is the inline event handlers (like <div onclick=''>) in Pale Moon have lost access of their arguments.

From https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes#event_handler_attributes:
All event handler attributes accept a string. The string will be used to synthesize a JavaScript function like function name(/*args*/) {body}, where name is the attribute's name, and body is the attribute's value. The handler receives the same parameters as its JavaScript event handler counterpart — most handlers receive only one event parameter, while onerror receives five: event, source, lineno, colno, error. This means you can, in general, use the event variable within the attribute.
A way to test the problem is as follows:

Code: Select all

<!DOCTYPE html>
<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The onclick Event</h2>

<p>The onclick event triggers a function when an element is clicked on.</p>
<p>Click to trigger a function that will output "Hello World":</p>

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  console.log(event);
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>
1. Save the demo code above as an html file and open it
2. Click "Click me"

All browser other than Pale Moon will output "Hello World".

User avatar
Moonchild
Project founder
Project founder
Posts: 39633
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Inline event handlers lost their arguments

Post by Moonchild » 2026-07-07, 11:19

Not sure why you're seeing an issue, considering the demo code you posted works just fine. (win 10 x64/Pale Moon 34.3.1 x64)

Event logged in console:

Code: Select all

13:18:30.970 click { target: <button>, buttons: 0, clientX: 22, clientY: 214, layerX: 22, layerY: 214 } 1 test.html:15:11
I found the report peculiar since we haven't touched those handlers for quite a while... and I'd also expect there to be a lot of breakage reports if it was broken ;)
"Sales hates anything that can't be turned into a confident sentence." - anonymous warehouse worker
"Why debate someone you fundamentally don't trust?" - Dario Amodei
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
seadragon
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2021-06-18, 04:39

Re: Inline event handlers lost their arguments

Post by seadragon » 2026-07-07, 11:23

Thank you for the reply. It's strange... Let me reinstall Pale Moon and see if the problem vanished. If not, I will provide more troubleshooting information.

User avatar
jobbautista9
Board Warrior
Board Warrior
Posts: 1237
Joined: 2020-11-03, 06:47
Location: Philippines

Re: Inline event handlers lost their arguments

Post by jobbautista9 » 2026-07-07, 11:26

dom.window.event.enabled in about:config needs to be true for the testcase to work.
Image

Tired of creating stuff!

Avatar artwork by Shinki669: https://www.pixiv.net/artworks/113645617

XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.

User avatar
seadragon
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2021-06-18, 04:39

Re: Inline event handlers lost their arguments

Post by seadragon » 2026-07-07, 11:30

jobbautista9 wrote:
2026-07-07, 11:26
dom.window.event.enabled in about:config needs to be true for the testcase to work.
It is the problem. I'm not sure why the default value is false

User avatar
jobbautista9
Board Warrior
Board Warrior
Posts: 1237
Joined: 2020-11-03, 06:47
Location: Philippines

Re: Inline event handlers lost their arguments

Post by jobbautista9 » 2026-07-07, 11:35

seadragon wrote:
2026-07-07, 11:30
I'm not sure why the default value is false
Because it is a deprecated property (it was a non-standard introduced first by IE iirc before it got written into the living standard for DOM when Blink and WebKit refused to remove support for it due to how widespread its usage is) which we were trying to discourage using (and still are as you can see with it being disabled by default). Even Mozilla which introduced support for window.event very late (version 66) made it clear in their MDN that it is not recommended to use it: https://developer.mozilla.org/en-US/doc ... ndow/event
Image

Tired of creating stuff!

Avatar artwork by Shinki669: https://www.pixiv.net/artworks/113645617

XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.

User avatar
seadragon
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2021-06-18, 04:39

Re: Inline event handlers lost their arguments

Post by seadragon » 2026-07-07, 11:44

My feeling is that this feature has some real use cases in the wild and disabling it by default will cause some real web compatibility issues (I found this problem while testing my own web project). Nevertheless, as this kind of default setting is by design, I have no objection to that.

To be absolutely sure that this is the cause, I would like to know if Moonchild has this flag on so that the demo works?

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2572
Joined: 2018-05-05, 13:29

Re: Inline event handlers lost their arguments

Post by vannilla » 2026-07-07, 12:17

To make the event handler work without relying on the deprecated global event and the about:config flag being toggled, it should be written like so:

Code: Select all

function handler(event) {
  console.log(event);
}
and used like this:

Code: Select all

<button onclick="handler(event)">Click me</button>
Or you can write the function body directly inside the string:

Code: Select all

<button onclick="targetelement.innerHTML = 'Hello world'">Click me</button>
Or use addEventListener if you can, since its behaviour is less confusing.

User avatar
seadragon
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2021-06-18, 04:39

Re: Inline event handlers lost their arguments

Post by seadragon » 2026-07-07, 12:42

Thank you very much. I always thought that I was using the event passed into the event handler, while actually I was using the deprecated window.event.

Pale Moon helps me understand how to write in a more standard way, and I am grateful for that.

User avatar
Moonchild
Project founder
Project founder
Posts: 39633
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Inline event handlers lost their arguments

Post by Moonchild » 2026-07-07, 14:46

Ah yes I missed that because my current profile has it flipped on, and I didn't look too closely at the code since it worked and on* stuff is mature and stable. Sorry about that.

Indeed, the proper way to use this is to pass the event into the event handler. The global event is fragile and may not always have the expected value (in any browser, not just us).
"Sales hates anything that can't be turned into a confident sentence." - anonymous warehouse worker
"Why debate someone you fundamentally don't trust?" - Dario Amodei
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite