lilanghua 发表于 2019-11-28 09:08:17

怎么引用一个外部js文件?

怎么引用一个外部js文件,我上传了一个js文件到资源,然后用表单里的html控件,把资源中的js文件嵌入,好像没运行。

lilanghua 发表于 2019-11-29 15:23:22

我这脚本文件是从资源文件里上传上去的,然后在表单的Formload事件调用:
new Element("script", {
"type": "text/javascript",
"href": "http://ip地址:20020/x_processplatform_assemble_surface/jaxrs/file/1bd9b39d-fef2-45ff-8fd8-2f7f18abf2c4/application/eec86c4f-c020-456a-9e54-c770c8151e03/content"
}).inject($(document.head));
脚本里面内容如下:
function getInfo(s){        alert(s);}form load里面调用getInfo("123")或者this.getInfo("123")都报错,说getInfo未定义啥的。

lilanghua 发表于 2019-12-2 10:42:24

好的,果然可以了。

论坛管理员 发表于 2019-11-29 13:20:20

客气客气!

lilanghua 发表于 2019-11-29 11:21:33

好的,谢谢

论坛管理员 发表于 2019-11-28 18:07:31

可以使用
new Element("script", {
"type": "text/javascript",
"src": "js地址"
}).inject($(document.head));

论坛管理员 发表于 2019-11-29 17:03:25

不好意思,,我写错单词了,
应该是src而不是 href
页: [1]
查看完整版本: 怎么引用一个外部js文件?