cancel
Showing results for 
Search instead for 
Did you mean: 
OleksandrB
Sisense Team Member
Sisense Team Member

How to change the color of the links in the Text widget?

To change the color of the link, please do the following.

Press 3 dots on the Text widget - Edit Script, paste next script, and press the Save button:

const customStyle = {
    color: 'red'
};

widget.on('initialized', () => {
    const computedStyles = getStyles();
    const fakeDiv = document.createElement('div');
    fakeDiv.innerHTML = widget.style.content.html;
    const fontElements = fakeDiv.getElementsByTagName('a');
    for (let i = 0; i < fontElements.length; i++) {
        fontElements[i].style = computedStyles;
        fontElements[i].setAttribute('target', '_blank'); 
    }
    widget.style.content.html = fakeDiv.innerHTML;
});

function getStyles() {
    let newStyles = '';
    for (let key in customStyle) {
        newStyles += `${key}: ${customStyle[key]};`;
    }
    return newStyles;
}

 

As the result, we will have a red color on the link

 

OleksandrB_0-1707413499846.png

 

 

Disclaimer: This blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their environment before deploying them to ensure that the solutions proffered function as desired. To avoid doubt, the content of this blog post is provided to you “as-is” and without warranty of any kind, express, implied, or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this post incorporates custom coding, which is outside the Sisense product development environment and is, therefore, not covered by Sisense warranty and support services.

Rate this article:
Version history
Last update:
‎02-14-2024 10:04 AM
Updated by: