Connecting Tech Pros Worldwide Help | Site Map

Contents of a <script> element

  #1  
Old November 3rd, 2005, 09:45 PM
Christopher Benson-Manica
Guest
 
Posts: n/a
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.
  #2  
Old November 3rd, 2005, 11:05 PM
RobG
Guest
 
Posts: n/a

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
  #3  
Old November 3rd, 2005, 11:25 PM
Evertjan.
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read <customErrors> element via VB.NET Code? =?Utf-8?B?TWlrZQ==?= answers 9 February 8th, 2007 10:35 PM
<noscript> alternative for random image changer Spartanicus answers 7 July 27th, 2006 12:45 AM
javascript outside of <html> tags taras.di@gmail.com answers 2 December 19th, 2005 01:25 PM
modifying and writing contents of a textRange sentinel answers 6 July 23rd, 2005 12:51 PM