springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-18 14:00:37
117
我正在尝试从一个网站加载一些HTML和JavaScript,而不使用iframe.我可以呈现HTML、CSS,并且似乎正在加载JavaScript文件,但我无法从加载的内容中调用函数。
我正在尝试使用FETCH加载:
window.onload = function () {
fetch(myURL)
.then(function (response) {
return response.text();
})
.then(function (body) {
var dv = document.createElement('div');
dv.innerHTML = body;
document.body.appendChild(dv);
//trying to call function here after appending the html content to my page
});
}();
有没有可能,或者浏览器出于安全原因阻止了它?
顺晟科技:
您必须显式添加脚本元素。所以可以肯定的是:
let text = "<h1>Test</h1><script>const callMe = () => { alert('called'); }" + "</script>";
const scriptStart = text.indexOf('<script>');
const scriptEnd = text.indexOf('</script>');
const script = text.substring(scriptStart + "<script>".length, scriptEnd);
text = text.substring(0, scriptStart) + text.substring(scriptEnd + "</script>".length);
element.innerHTML = text;
const scriptElement = document.createElement("script");
scriptElement.innerHTML = script;
document.head.appendChild(scriptElement);
callMe();
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11