本文介绍了如何获取脚本标签的innerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧...我一直在寻找一个小时...怎么得到一个脚本标签的innerHTML?这是我一直在做的...

Alright... I've been searching for an hour now... How does one get the innerHTML of a script tag? Here is what I've been working on...

<script type="text/javascript" src="http://www.google.com" id="externalScript"></script>
<script type="text/javascript">
function getSource()
 {document.getElementById('externalScript').innerHTML;
  }
</script>

我一直在尝试使用脚本标签调用另一个域的页面源代码。我已经看到了一个工作示例,但找不到它的生活。

I've been trying to work on a way to call another domain's page source with the script tag. I've seen a working example, but cannot find it for the life of me...

推荐答案

那。没有innerHTML ....所有你可以做的是拉下文件视图XMLHttpRequest获取到其内容....但当然,这是受限于同源策略,但脚本标签不是。很抱歉。

You can't do that. There is no innerHTML....all you can do is pull down the file view XMLHttpRequest to get to its contents....but of course, that is limited by same-origin policy, but script tags are not. Sorry.

这篇关于如何获取脚本标签的innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 11:36