开发者

How to extract javascript contents

开发者 https://www.devze.com 2023-02-27 19:04 出处:网络
As we extract html contents using alert(document.all开发者_开发问答[0].innerHTML); how can i extract javascript contents.

As we extract html contents using

alert(document.all开发者_开发问答[0].innerHTML);   

how can i extract javascript contents.

Anyone who knows the answer, please help me Thanks in advance.


var firstScript = document.getElementsByTagName('script')[0];
alert(firstScript.innerHTML);


You can use Ajax to grab the script's contents--they are not automatically exposed to an API when a script tag is added--only executed. But if you are thinking of executing the code later on, you could use eval() to do so, but bearing in mind that this can cause security problems for your site if the code is obtained in whole or part from untrusted sources.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号