Capturing the output of a script src tag

Discussion in 'Javascript' started by ebobnar, Mar 3, 2004.

  1. ebobnar

    ebobnar Guest

    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
    ebobnar, Mar 3, 2004
    #1
    1. Advertising

  2. 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
    Brian Kerrick Nickel, Mar 4, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Richter

    <txt src= ...> equivalent of <img src= ...>

    Steve Richter, Feb 8, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,063
    Laurent Bugnion
    Feb 9, 2006
  2. Greg Johnson
    Replies:
    4
    Views:
    3,051
  3. shruds
    Replies:
    1
    Views:
    757
    John C. Bollinger
    Jan 27, 2006
  4. Replies:
    1
    Views:
    1,602
    Alex Hunsley
    Mar 23, 2007
  5. pheadxdll
    Replies:
    16
    Views:
    3,618
    Neredbojias
    Jun 6, 2007
Loading...

Share This Page