Connecting Tech Pros Worldwide Help | Site Map

Contents of a <script> element

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 3rd, 2005, 08:45 PM
Christopher Benson-Manica
Guest
 
Posts: n/a
Default Contents of a <script> element

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, 10:05 PM
RobG
Guest
 
Posts: n/a
Default 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, 10:25 PM
Evertjan.
Guest
 
Posts: n/a
Default 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)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.