【发布时间】:2020-12-27 07:59:41
【问题描述】:
我在 Dynamics 365 表单上注册了我的 JavaScript 函数:
我的代码运行良好(TypeScript 转译的结果):
var Softline_Stuff;
(function (Softline_Stuff) {
function hello() {
alert("Hello, World! v2");
}
Softline_Stuff.hello = hello;
})(Softline_Stuff || (Softline_Stuff = {}));
//# sourceMappingURL=isv_stuff.js.map
但是,如果我尝试根据包含我的代码的 script 元素来查找,那么我什么也没找到。我在浏览器的控制台 (Google Chrome) 中运行此代码:
// Search inside of main document and child documents are located in iframes:
let docs = [document];
for(let frameIndex = 0; frameIndex < frames.length; frameIndex++) {
docs = [...docs, frames[frameIndex].document];
}
for(let doc of docs) {
const tags = doc.getElementsByTagName('script');
for(let index = 0; index < tags.length; index++) {
// Check src attribute value
const path = tags[index].getAttribute("src");
if(path && path.includes("isv_")){
console.log(path);
}
// if src value is null it means script is inlined
else if(!path) {
const code = tags[index].textContent;
// My code contains this string:
if(code && code.includes("Hello, World!")){
console.log(code);
}
}
}
}
如何找到直接包含我的代码或通过scr属性指向它的script元素?
【问题讨论】:
标签: javascript dynamics-crm microsoft-dynamics