Matrix Version:5.5.1.3
Hi,
I try to access Dom from server side script below
var links = document.getElementsByTagName('a');
var arr = [].slice.call(links);
if(arr.length > 1){
arr.forEach(function(link){
var href = link.href;
if(href.endsWith("pdf") || href.endsWith("PDF")){
var classes = link.className;
if((!classes.indexOf('btnLink') !== -1) && (!classes.indexOf('btnLink') !== -1) && !link.getElementsByTagName('img')[0]){
var pdfUrl = href;
pdfUrl = pdfUrl.substring(8);
var res = pdfUrl.split("/");
var pdf = res[5];
var fileSize = "%globals_asset_file_size_readable:"+pdf+"%";
var el = document.createElement("span");
el.innerHTML = " [PDF]";
link.parentNode.insertBefore(el, link.nextSibling);
}
}
});
}
However this does not work at all. If I try this in normal js, it works
Also I tried to execute keywords in normal js file like
var pdfUrl = res[5];
var pdf = "%globals_asset_file_size_readable:"+pdfUrl+"%";
But when I print out pdf, it does not show file size, shows %globals_asset_file_size_readable:1234%
Is there any way to implement this?