Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
abhishek6555
Frequent Visitor

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 2
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.

Syndicate_Admin
Administrator
Administrator

I, too, am looking for that answer.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.