Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Capturing the output of a script src tag

Reply
Thread Tools

Capturing the output of a script src tag

 
 
ebobnar
Guest
Posts: n/a
 
      03-03-2004
I'm sure you all have seen how using the src argument in a script tag
is essentially the same as including the body of the script within
your page. For example:

<script type="text/javascript"
src="http://somepage.com/somead/show_ads.js">
</script>

Is there a way to capture the html output of that script and save it
to a variable or text file so that I can use a language like php to
parse it and look for certain words or phrases?

For instance, this particular url executes some javascript code which
produces an iframe on my page, but view source only displays the
script tag. Using innerHTML I can get the iframe code to print in
another browser window, but I would prefer the iframe html be save to
a variable or text file so that I can write a script to parse it on
the fly.

Please let me know if I'm being unclear and I'll try rephrasing my
problem.

Thanks a lot

ebobnar
 
Reply With Quote
 
 
 
 
Brian Kerrick Nickel
Guest
Posts: n/a
 
      03-04-2004
This is a beautiful trick that works in lots of languages, you steal
control of the writing function:

<script type="text/javascript">
var write_output = "";
var document_write = document.write;
document.write = function( )
{
for( var i = 0; i < arguments.length; i ++ )
write_output += arguments[ i ].toString( );
};
</script>
<script type="text/javascript" src="look_at_me_I'm_an_ad.js"></script>
<script type="text/javascript">
document.write = document_write;
// Now you can read write_output
</script>

Have fun and good luck socking it to the crappy-ad-writing man.


..Brian
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<txt src= ...> equivalent of <img src= ...> Steve Richter ASP .Net 3 02-09-2006 08:44 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Using <script src> tag, is type required? Randell D. Javascript 4 12-25-2003 06:38 AM
Problem with <script> tag using runat=server and src attributes John MacIntyre Javascript 1 09-29-2003 08:07 AM
src.jar (src.zip) missing on Mac OSX Java 1.4.1 installation? Greg Johnson Java 4 09-18-2003 07:21 AM



Advertisments