从Blogger导入不带标记的JavaScript文件



我尝试在不使用<脚本src=我尝试了document.write,但导入完成后,原始页面内容将被删除有没有一种方法可以在不使用<脚本

<button onclick="myFunction()">Click me</button>
<h1>Test Content</h1>
<script>
function myFunction() {
// The problem here is deleting the text content With document
// And I tried Use document.createElement
// Is there any other way to call and run the file codes ?
document.open();
document.write('<script type="text/javascript" src="https://photoshop4all.com/feeds/posts/default?max-results=5&alt=json-in-script&callback=URLAGAIN"></script>');
document.close();

}

function URLAGAIN(json) {

document.write(json.feed.entry[0].link[1].href);


}
</script>

请参阅:https://www.w3schools.com/JSREF/met_doc_open.asp

open((方法打开一个输出流,以收集任何document.write((或document.writeln((方法的输出。

执行完所有写入操作后,document.close((方法将显示写入输出流的任何输出。

CCD_ 1。

注意:不要将此方法与window.open((方法混淆,后者会打开一个新的浏览器窗口。

您可以在这里看到如何插入带有js 的脚本

最新更新