By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,034 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,034 IT Pros & Developers. It's quick & easy.

How does Google show_ads.js work?

P: n/a
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

Jun 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 23 Jun 2006 02:41:45 -0700, JohnSouth wrote:
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
Jun 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.