Reply
abhishek6555
Frequent Visitor
Partially syndicated - Outbound

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
avatar user
Anonymous
Not applicable

Syndicated - Outbound

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

Source Community: Power BI Spanish | Source Author Name: JrGregorioHPV
Syndicated - Inbound

I, too, am looking for that answer.

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)