Forum Discussion

abhishek6555's avatar
abhishek6555
Frequent Visitor
3 years ago

how to add html which has javascript in power bi desktop

I am trying to add this below scripts which has html and javascrpt using html content visual. However the javascript part does not work. How to fix this

 

 

<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<style>
/* CSS code goes here */
#welcome {
color: blue;
cursor: pointer;
}
#welcome.clicked {
color: red;
}
</style>
<script>
// JavaScript code goes here
window.addEventListener('DOMContentLoaded', () => {
const welcome = document.getElementById('welcome');
welcome.addEventListener('click', () => {
welcome.classList.toggle('clicked');
});
});
</script>
</head>
<body>
<!-- HTML code goes here -->
<h1 id="welcome">Welcome</h1>
</body>
</html>

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You must ensure that all quotes in your HTML code are single quotes ' and never double quotes ". This is because the measure will not interpret double quotes correctly. By making this change, your code should work as expected.