question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error inline event define

See original GitHub issue

Hi if define inline event in html tag so ->

<div onclick="callfunction()" >test </div>

(this div generate at runtime and dono’t know its ID )

and callfunction define into compiled script file (with bytenode)

when click on div this error was showed : callfunction don’t define

how work with this situation ?

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
OsamaAbbascommented, Dec 15, 2022

A better approach will be to import the whole module and attach it to the window object once.

Like this:

// render2.js

const bytenode = require("bytenode");

require("./render.jsc");

window.MY_API = require("./render.jsc");

Then, in your html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello World!</title>
    <script defer src="render2.js"></script>
  </head>
  <body class="content">
    <button id="btn1" onclick="MY_API.testfunc()">testclick</button>
  </body>
</html>
0reactions
ngohuytrieucommented, Dec 15, 2022

@samantrader technically you need to export your functions and then import them in order to use them in other files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline event handler error for button onclick event Javascript ...
Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src-attr 'none'". Either ...
Read more >
inline event handler linting · Issue #123 - GitHub
For all inline event handlers treat event as defined (and for onerror treat source , lineno , colno , and error as defined)...
Read more >
How to Fix ReferenceError: Event is Not Defined in JavaScript
The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.
Read more >
Event handling (overview) - Event reference - MDN Web Docs
Events are signals fired inside the browser window that notify of changes in the browser or operating system environment.
Read more >
Inline hooks - Okta Developer
Okta defines several different types of inline hooks. Each type of inline ... How the error data is used varies by inline hook...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found