如何获取指定为< script>的'src'的文件内容?标签? [英] How can I get the content of the file specified as the 'src' of a <script> tag?

查看:119
本文介绍了如何获取指定为< script>的'src'的文件内容?标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有这样的脚本标记:

If I have a script tag like this:

<script
    id = "myscript"
    src = "http://www.example.com/script.js"
    type = "text/javascript">
</script>

我想获取script.js文件的内容。我正在考虑像 document.getElementById(myscript)。text 这样的东西,但在这种情况下它不起作用。

I would like to get the content of the "script.js" file. I'm thinking about something like document.getElementById("myscript").text but it doesn't work in this case.

推荐答案

您想要获取文件的内容 http ://www.example.com/script.js ?如果是这样,您可以转向AJAX方法来获取其内容,假设它与页面本身位于同一服务器上。

You want to get the contents of the file http://www.example.com/script.js ? If so, you could turn to AJAX methods to fetch its content, assuming it resides on the same server as the page itself.

您能详细说明您正在尝试的内容吗?去完成?

Could you elaborate on what you're trying to accomplish?

这篇关于如何获取指定为&lt; script&gt;的'src'的文件内容?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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