RobG wrote on 03 nov 2005 in comp.lang.javascript
:
Christopher Benson-Manica wrote: I would like to, for debugging purposes, obtain the contents of a
<script> element. I'm aware that the text property contains the text
contained within the element. However, the <script> element I'm
interested is an external script, specified with the src attribute.
Is there a way to access the linked contents of such an element?
View the page source, build a URL from the src attribute of the script
element and past it into your browser's address bar.
Many browsers will download the script file (along with all the other
page content) if you use 'Save as'.
If it is not a frames-page, paste this as one line in your address bar:
javascript
:t='';g=function(d){x=d.styleSheets;for( i=0;i<x.length;i++){m
('link',x[i].href);y=x[i].imports;for(j=0;(y&&j<y.length);j++)m('@import',y
[j].href)}z=d.getElementsByTagName('script');for(k=0; k<z.length;k++)m
('script',z[k].src)};m=function(n,s){if(s){if(a){a=0;t+='<br>fra me<br>'}
t+='['+n+']\t<a\thref='+s+'>'+s+'</a><br>'}};a=0;g(document);f=frames;for
(h=0;h<f.length;h++){a=1;try{g(f[h].document)}catch(e){}}with(open
('','','width=620,height=140,scrollbars,resizable' ).document){write
(t);close()}
[or make a favelet/bookmarklet of it.]
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)