I'm trying to change styles of many text fields on a layout of an application in RSA Archer GRC using custom object. I wrote a script and it runs only once, when the application is opened. The problem is that the layout contains multiple tabs. When tab is changed the script isn't working anymore. So how to execute the script on every tab changing?
var tableId = 'master_DefaultContent_rts_ts3295_s4655_f18821srvgrid_ctl00';
//table with target elements
$(document).ready(function () { //run script when page is loaded
main();
});
function main() {
var table = document.getElementById(tableId).getElementsByTagName("tbody")[0];
var rows = table.getElementsByTagName("tr");
for (var i = 0; i < (rows.length - 1); i++) {
var field = rows[i].getElementsByTagName("td")[1];
var spanElements = field.getElementsByTagName("span"); //target elements
for (var k = 0; k < spanElements.length; k++) { //apply style for each of them
var elem = spanElements[k];
elem.style.fontFamily = "Times New Roman";
elem.style.fontSize = "14pt";
elem.style.color = "black";
}
}
}
Try using this in your custom object instead of $(document).ready({});
, it should fire each time a tab is loaded.
function pageLoad(){
//code
}