Platform
Resources
Pricing
Sign in
Get started
Thomas Ballinger
Workspace
Fork
Published
By
Thomas Ballinger
Edited
May 25, 2020
Insert cell
Insert cell
Insert cell
{
const
stuff
=
html
`<h2>Hello</h2><script type="module">console.log('asdf');</script>`
;
runScript
(
html
`<script>
console.log("Script is running now.");
document.getElementsByTagName('h2')[0].style.color = 'green';
</script>`
)
;
return
stuff
;
}
Insert cell
function
runScript
(
script
)
{
// setTimeout so that DOM you wanted to manipulate is probably mounted
setTimeout
(
(
)
=>
{
var
newScript
=
document
.
createElement
(
"script"
)
;
newScript
.
text
=
script
.
text
;
newScript
.
type
=
script
.
type
;
document
.
head
.
appendChild
(
newScript
)
;
//.parentNode.removeChild(script);
}
)
;
}
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
runScript
Unpin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML