Connecting Tech Pros Worldwide Help | Site Map

Contents of a <script> element

Christopher Benson-Manica
Guest
 
Posts: n/a
#1: Nov 3 '05
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?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
RobG
Guest
 
Posts: n/a
#2: Nov 3 '05

re: Contents of a <script> element


Christopher Benson-Manica wrote:[color=blue]
> 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?
>[/color]

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



--
Rob
Evertjan.
Guest
 
Posts: n/a
#3: Nov 3 '05

re: Contents of a <script> element


RobG wrote on 03 nov 2005 in comp.lang.javascript:
[color=blue]
> Christopher Benson-Manica wrote:[color=green]
>> 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?
>>[/color]
>
> 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'.[/color]

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)

Closed Thread