How does Google show_ads.js work?

J

JohnSouth

Hi

I'm hoping to set up a system similar to Google Adwords that allows
other sites to extact a limited amount of data from my site, and
display it as part of their webpage. Google use a javascript file:
show_ads.js with parameters.


Can anyone explain how the .js file works? In particular how does it
output HTML back to the calling site, and how does it access the
parameters?

Cheers

John South
www.WhereCanWeGo.com
 
R

Richard Gration

Hi

I'm hoping to set up a system similar to Google Adwords that allows
other sites to extact a limited amount of data from my site, and
display it as part of their webpage. Google use a javascript file:
show_ads.js with parameters.


Can anyone explain how the .js file works? In particular how does it
output HTML back to the calling site, and how does it access the
parameters?

You can "fake" javascript file content. You write a cgi that returns valid
javascript and specify this as the source of the <script> tag eg (untested)

In html document:
....
<head>
<script type="text/javascript" language="JavaScript"
src="http:/www.yoursite.com/cgi-bin/js.pl"></script>
....

in js.pl:

#!/usr/bin/perl

use CGI qw(&header &cookie);
use strict;
use warnings;

my $cookie1 = cookie('cookie1');
print header('text/javascript');
print qq(var cookie1 = '$cookie1';);

Extending this idea, you can also have your "fake" javascript file return
html into valid javascript and place the script tag in your document body
at the place you want it printed eg.

<body>
....
<script type="text/javascript" language="JavaScript"
src="http:/www.yoursite.com/cgi-bin/js.pl"></script>
....
</body>

and in js.pl:

#!/usr/bin/perl

use CGI qw(&header);
use strict;
use warnings;

print header('text/javascript');
print <<EOT;
document.write('blah blah blah');
document.close();
EOT

HTH
Rich
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top