Does hashnode widget support Javascript

·

1 min read

First let's make a simple widget named `alert`:

<script>
console.log('hello from widget');

let count = 0;

function click_button(){
    let str = `click button from widget ${++count} times`;
    console.log(str);
    document.getElementById("demo").innerHTML = str;
    alert(str);
}
</script>
<style>
button {
    padding: 5px 10px;
}
</style>
<p id="demo"></p>
<button onclick="click_button()">click to alert</button>

Then add it to article:

%%[alert]

It's proven that Javascript is allowed but alert function doesn't work. Can you see an alert dialog?