如何附加<脚本>< / SCRIPT>在JavaScript? [英] How to Append <script></script> in javascript?

查看:141
本文介绍了如何附加<脚本>< / SCRIPT>在JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用childappend或jQuery的追加()一些标签的东西附加到文档中。从我所知,这是越来越剥离出来。任何人都知道该怎么办呢?

I need to use childappend or jquery append() to append some tag stuff into the document. From what I can tell, this is getting stripped out. Anyone know how to do it?

推荐答案

试试这个:

var s = document.createElement("script");
s.type = "text/javascript";
s.src = "http://somedomain.com/somescript";
$("head").append(s);

请注意,该脚本将加载并可以访问它里面的变量,但你不会看到实际的<脚本方式> 标记在DOM

Note that the script will load and you can access the variables inside it, but you wouldn't see the actual <script> tag in the DOM.

这篇关于如何附加&LT;脚本&GT;&LT; / SCRIPT&GT;在JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆