mjboothaus
mjboothaus10mo ago

JavaScript in mo.Html

<div id="message">Click the button to change this text.</div>
<button onclick="changeText()">Click Me!</button>

<script>
function changeText() {
document.getElementById('message').innerHTML = "Hello, Marimo with JavaScript!";
}
</script>
<div id="message">Click the button to change this text.</div>
<button onclick="changeText()">Click Me!</button>

<script>
function changeText() {
document.getElementById('message').innerHTML = "Hello, Marimo with JavaScript!";
}
</script>
7 Replies
Akshay
Akshay10mo ago
We don’t execute user scripts in JS for security reasons. What is your use case? If you want to a custom plugin you could try extending AnyWidget (see our docs). You can also embed html in iframes
mjboothaus
mjboothausOP10mo ago
Oh -- ok thanks for super quick reply
Akshay
Akshay10mo ago
If it’s very important for you to run scripts we can consider designing an API around that, not something has been requested yet Yup np
mjboothaus
mjboothausOP10mo ago
Ticker Tape
Embed free widgets in your website or blog. Stock market quotes, Forex, Bitcoin, Index and Futures data in the functional HTML5 widgets by TradingView.
mjboothaus
mjboothausOP10mo ago
Example of the JS widget I was basically just test driving this example - I use Streamlit.io in general for app delivery - was looking for an app-lite alternative I will take a look at AnyWidget and iFrame options too. Cheers! Very impressive offering so far Can you point me to (non-tutorial) examples for further inspiration? p.s. I don't do trading... was just an example 🙂
Akshay
Akshay10mo ago
Ya there are some in the share-your-notebook channel And others at marimo.io/@public
Tony S
Tony S9mo ago
Hi there, I wanted to follow up on this question because I have a need for injecting javascript into my app. We currently have a need to utilize 3dmol.js (http://3dmol.csb.pitt.edu) to visualize and manipulate molecules in 3D. The most sensible way at the moment is injecting into a marimo Html component, but it seems like it is not executing, which makes sense based on your answer to this question. Is a way around this?