In my project i have to retrieve the content in all script tags. I am able to do this by simply including
var scrpt=document.getElementsByTagName('script');
script_txt=scrpt[i].innerHTML;
but by using the above code i am not getting dynamic scripts which are created by
var s=document.createElement('script');
s.src="http://somefile.js";
not only this there are many other ways of creating dynamic scripts like
document.write('<script src="">');
and
document.body.innerHTML='<script src="">';
and many more. I tried to retrieve it by using regular expressions like this
var pattern=/([a-zA-Z0-9_\.].*?)=(document.createElement\((.*)\));
/g;
but this may not match all.
Can anyone suggest a better method for achieving this property.
document.scriptsis an HTML5 feature and therefore not suitable on the general web since many browsers don't support it.