How to get a Script Tag's innerHTML

前端 未结 5 1775
梦如初夏
梦如初夏 2021-01-19 20:02

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...



        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 20:39

    actually, there is a way to get the content, but it depends on the remote server letting you get the file without valid headers and still fails a lot of the time just because of those settings. using jQuery since it's the end of my day and I'm out the door....

    $.get($('#externalScript').attr('src'), function(data) {
        alert(data);
    });
    

提交回复
热议问题