Question

How to Make an Ad Server in Javascript

Asked by: Tx74Qp853mR

Experts,

I need to create an advertising server in javascript.

The goal is to serve ads (could be text, image, or flash ads) to an html page on a "fixed rotation", driven by the number of visits to the page.

By "fixed rotation" I mean that every visit to the html page would show the visitor a different ad from a set of N ads, in a circular rotation, as follows:

The first visitor would see ad_1, the second visitor would see ad_2 (regardless of whether the first and second visitors are the same visitor or different visitors), visitor N would see ad_N, visitor N-plus-1 would see ad_1, and so on.

The ad slot in the html page would probably contain the following code, or something similar:

<script type="text/javascript"
    src="http://domain/adserver.js">
</script>

The html page and the ad server script would be on the same Linux server.

Obviously, there needs to be some way to store the ad index between calls to the script, and to increment the ad index at every script run.

I'm looking for a simple and efficient solution, i.e. minimizing server load.

I know this is possible, but I don't know how to do it.

Your ideas are welcome.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-12-13 at 15:22:57ID23982689
Tags

javascript

Topics

JavaScript

,

Scripting Languages

,

Web Development

Participating Experts
5
Points
500
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Ad Rotator
    Hi, I would like to know how to make an ad rotator whereby the ad keeps rotating every couple of seconds.i tried the ad rotator component but what is happening is that the ad rotates whenever you visit the page the next time.It does not happen automatically as it does on so...
  2. Ad Rotator + Flash
    Is there a way to integrate a .swf with a .gif, using the Ad Rotator?
  3. circular motion
    I have made an aeroplane how do I make it move in a circular formation? Also to have a smoke coming from its tail?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dbruntonPosted on 2008-12-14 at 01:56:33ID: 23167161

Well no.  You won't do it in javascript.  That's client based stuff.

You'll do the ad stuff on the server.  You'll have a server that supports one of the scripting languages; don't ask me which one; others will comment on that.

The server/scripting language will increment the ad index every time a request is made for the html page and dish out the correct page.

 

by: Tx74Qp853mRPosted on 2008-12-14 at 05:17:14ID: 23167586

Google uses javascript to at least invoke the ad server, if not to actually serve the ads... I have no idea what's behind their show_ads.js javascript, but it clearly is javascript being called.

Here's a typical adsense call:

<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxx";
google_ad_slot = "yyyyyyyyy";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

 

by: Tx74Qp853mRPosted on 2008-12-15 at 15:46:55ID: 23179353

Moderator,

This question is not drawing expert comments.  Do you have any suggestions ?

 

by: b0lsc0ttPosted on 2008-12-17 at 16:32:52ID: 23199742

Server script would be a key to this.  Can your Linux server support one (e.g. ASP, PHP, .NET, Perl)?  Most likely not the first or third but PHP would be nice and is pretty common on Linux servers.

Cookies will be an important part of this.  They don't require server script but would be the only way to have the server know what the page last had (and not show the same ad twice).  Of course they run the risk of being blocked or deleted but it is what you would have to use.

As far as comparing what Google does that is how they make it work.  However the JS file in this case is probably generated by the server or works with server code.  Your browser gets the JS and sees it but the server made it.  That is why I said and agree with the expert above that server script is a key and would be most useful in this.  You don't actually need Javascript if the ad isn't rotating WHILE the page is in the browser.  If you want to minimize load, size, etc then server script also better.  When the visitor goes to the page the server script would look for the cookie, if found read the last ad done or if not then start with ad one and make the cookie, send the ad and update the cookie so it would reflect the ad sent.

Let me know how this helps or if you have a question.  I can provide details but need responses to this to know what details to provide. :)

bol

 

by: Tx74Qp853mRPosted on 2008-12-17 at 18:27:59ID: 23200240

bol,

My Linux server supports PHP.

As for the Google ad server, here's the way I understand it:

When a client browser requests a page that contains the AdSense code above, the browser pulls and runs the following JS from a Google server machine:

http://pagead2.googlesyndication.com/pagead/show_ads.js

That JS (directly or indirectly) then pulls the actual ad from a server machine (could be the same server or another server machine) and displays the ad in the client browser.

You are probably right... a Google JS most likely uses PHP or ASP or some other server script to actually push the ad.  But the above JS does not do it directly... I've looked at the code... the above JS only calls other JS (i.e. no calls to .php, .asp, etc.)

So, why not just push the ad directly with PHP or ASP, etc. ?

They must have a good reason.

AdSense ads don't rotate unless you reload the page, and even then, often times they don't rotate even IF you reload the page.

So I don't think they're using JS because they need to rotate ads while the page is in the browser (i.e. to rotate ads without the client requesting a reload, or a new page.)

We can talk about PHP later, but for now, why do you think AdSense relies so heavily on JS ?

 

by: b0lsc0ttPosted on 2008-12-17 at 19:06:12ID: 23200382

>> why do you think AdSense relies so heavily on JS ? <<

Hopefully my response to this will answer all of the other things.  It seems like some of my other stuff was ignored but, if that isn't key to answering this, then that doesn't matter and I don't need a response to it.

You said you looked at the code but that doesn't really mean much.  If you have used server scripts then you know they just send to the browser what you want them to send.  Using view source only shows the part of it.  An example of this is one page that shows a form, processes the form info, sends the email, and provides a thanks.  You might see 2 completely different web pages depending on the step.  However it can be done by one server page (i.e. the URL won't change).

The same can be done for files that don't end with a normal server side script extension.  In other words the file doesn't have to end with .asp, .aspx, .php, or .jsp to be a product of a server script.  EE is an example of this.  Their pages end with .html but are definitely not just static html pages.  All that needs to be done is have the server set up to process that file or extension.

I can't say for sure but am almost positive Google does this for the JS page.  It is the only way to have a dynamic JS page and what you see sounds dynamic.  You mentioned a "push" but that isn't really an option and involves some specific and special server set up and technology.  It definitely would not be efficient or needed for something like what you ask here.  ASP can't even do it.  PHP can with sockets I believe but it just would be overkill.

I didn't make this clear before because it seemed off topic for what you were asking.  From your response it seems I may have misread what you wanted.  The reason Google even provides the JS file is probably just because it needs to be something third party sites can use.  Since you are talking about ads just for your server and domain this isn't needed.  The JS file is handy when other domains need to access your "files" because without them including the JS file the browser won't allow the "cross domain scripting."

I hope this helps and covers what you are asking.  Let me know if you have a question on any of this.

bol

 

by: Tx74Qp853mRPosted on 2008-12-17 at 23:20:08ID: 23201229

bol,

Thanks for the detailed answer... I was curious about how AdSense serves ads, and about their use of JS.  Your point about cross domain scripting may be the key to why AdSense uses the .js extension on its script.

However, regarding my original question, I recognize that the AdSense approach is not necessary, and perhaps not even desirable, if it can be done with PHP on the same server (i.e. page, script, and ads all reside on the same server.)

However, for completion, I attached the AdSense JS, which comes from the above link, and I welcome your comments on it.

Also, please comment on a PHP solution to my original question, if you're so inclined.

 

by: Tx74Qp853mRPosted on 2008-12-17 at 23:47:35ID: 23201303

Also... previously, I should have said "serve" the ad... not "push" the ad.

I recognize that push and pull technologies are different, and I wasn't trying the mix the two.

Just a mental lapse :)

 

by: LilPosted on 2008-12-18 at 02:05:43ID: 23201921

This takes care of the ad serving, but to write into a text file to keep tabs how many times each ad displayed, will probably require a little more technology, most of which is probably readily available for you since you are on a linux server. please let me know what kind of webserver (Apache probably) you have installed and do you have php or Perl.

Meantime, for the ads: (This assumes that the ads are in a folder called "ads" which is parallel to the webpages folder, for example "html")

<BODY>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="Designer Shoes";
url="http://www.prada.com";
alt="prada.com";
banner="../ads/prada_banner.gif";
width="468";
height="60";
}
if (ad==2) {
txt="Travel with Us";
url="http://www.empresstravel.com/";
alt="empresstravel.com";
banner="../ads/empresstravel.gif";
width="468";
height="60";
}
if (ad==3) {
txt="Experts Exchange.com";
url="http://www.experts-exchange.com";
alt="expers-exchange.com";
banner="../ads/ee.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</SCRIPT>


BRGDS,
~Lil

 

by: mplungjanPosted on 2008-12-18 at 02:26:23ID: 23202016

@lil: That can be somewhat more elegant

<script><!-- begin
function crtAd(txt,url,alt,banner,width,height) {
	this.txt=txt;
	this.url=url;
	this.alt=alt;
	this.banner=banner;
	this.width=(width)?width:480;
	this.height=(height)?height:68;
}
 
var myAds = new Array(
new crtAd("Designer Shoes","http://www.prada.com","prada.com","/ads/prada_banner.gif"),
new crtAd("Travel with Us","http://www.empresstravel.com/","empresstravel.com","/ads/empresstravel.gif",400,50),
new crtAd("Experts Exchange.com","http://www.experts-exchange.com","experts-exchange.com","/ads/ee.gif")
); // note the lack of comma after the last item
var myAd = myAds[Math.floor(Math.random()*myAds.length)];
document.write('<center>');
document.write('<a href=\"' + myAd.url + '\" target=\"_top\">');
document.write('<img src=\"' + myAd.banner + '\" width=')
document.write(myAd.width + ' height=' + myAd.height + ' ');
document.write('alt=\"' + myAd.alt + '\" border=0><br>');
document.write('<small>' + myAd.txt + '</small></a>');
document.write('</center>');
// End -->
</script>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:

Select allOpen in new window

 

by: b0lsc0ttPosted on 2008-12-18 at 10:12:39ID: 23205811

I will post a PHP script example of how to do this since that was what you asked here.  The experts above have shown good examples of how to do this in Javascript.  Let me know if you have a question about the code or how to use it.  I added comments so it should be clear but I will be glad to elaborate if something needs details or explanation.

>> I was curious about how AdSense serves ads, and about their use of JS. <<

I am glad the details in my last post helped.  However it seems they were getting off topic and the comment quoted above (plus some of the other things you asked) are also different from this thread's question.  If you would like answers to them then you should open a new question.  I can't really add more about how adsense works though so am not sure it is worth a question.  The details you want are Google's and they protect their "secrets" well.  My info on it is probably correct (at least generally) but is an educated "guess."  I appreciate you attaching the file but that topic has distracted me enough from what you asked here and I don't like to continue "guessing" (no matter how right I feel I am).

I hope the above helps.  Let me know if you have a question about anything I have said.

bol

<?php
// this code needs to be before any code that would send something to the browser
 
$aAds = Array("adFile1.gif","adFile2.gif","adFile3.gif"); // array for images used in ad
// might need other array for a URL to the ad's "site"
 
if (isset($_COOKIE['adFile'])) {
	$nAd = $_COOKIE['adFile'];
	$nAd = ($nAd * 1) + 1;
} else {
	$nAd = 0;
}
// use this line or section to make the html for the ad
//   the number from the cookie is used to determine which ad to show (from array(s))
 
$_COOKIE['adFile'] = $nAd; // write cookie
 
// rest of page with html and php sending html
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:

Select allOpen in new window

 

by: Tx74Qp853mRPosted on 2008-12-18 at 10:40:58ID: 23206078

Lil, thanks for the code... the server is Apache, with Linux and PHP.

mplungjan, thanks for the code...

Both scripts implement a random ad index, using two different methods... excellent.

But if I wanted to store the ad index on the server between calls to the script... any ideas how to do that, and how to integrate the ad index (stored on the server) with your JS ?

The idea of storing the ad index on the server is to cycle through the ads in a fixed order (1,2... N, 1, 2, ...), as opposed to randomly.

bol, thanks for the code... wouldn't you need to set the cookie in the client, with something like:
setcookie("adFile",0,time()+3e6);

and increment the client cookie during each script run, with something like:
setcookie("adFile",$_COOKIE['adFile']+1,time()+3e6);

and reset the client cookie to zero again after all the ads have been exhausted ?

 

by: mplungjanPosted on 2008-12-18 at 10:47:30ID: 23206144

To cycle without server, use a cookie and not random

var idx = getCookie('adIdx')
if (idx >= myAds.length) idx = 0;
var myAd = myAds[idx];
setCookie('adIdx',++idx)

 

by: b0lsc0ttPosted on 2008-12-18 at 10:53:32ID: 23206201

>> wouldn't you need to set the cookie in the client <<

Nothing needs to be done in client script.  The PHP script tells the browser all it needs to make the cookie.  Javascript or other clientscript isn't required.

I did have an error in what I posted though.  The part to set the cookie is wrong.  Cold brain I guess because I can't see any other excuse for it. :)

The correct line for my line 16 above is ...

setcookie("adFile", $nAd, time() + 60 * 60 * 24 * $nDays);

The $nDays variable can be replaced with the number or used above that line to set the days.  The "days" would be how many days in the future should the cookie last.  An expiration date must be set but could be 30 days, 365 days, etc.

>> and reset the client cookie to zero again after all the ads have been exhausted ? <<

I did not include something in PHP to do that but it can be done there.  Below line 9 above you would add ...

if ($nAd >= count($aAds)) $nAd = 0;

Sorry for the error.  Remember the PHP script doesn't need any Javascript so you would not use both.  Let me know if you have a question or how this helps.

bol

 

by: b0lsc0ttPosted on 2008-12-18 at 10:58:33ID: 23206249

Just a "disclaimer" ... when I have said Javascript wasn't needed that is ONLY for what I have provided or recommended.  I am not trying to say you should not use the other's recommendation.  In their case there is no need for server script.  Personally I would always use server script for something like this but I don't want that personal opinion or the way I have phrased my responses to seem to be an argument against what the others are providing.  Which you use is up to what works best for you.  I would not combine the two though.  There is no reason or benefit to it.

bol

 

by: Tx74Qp853mRPosted on 2008-12-18 at 12:09:46ID: 23206840

Thanks all...

I did recognize that it's either the JS example(s) or the PHP example, but not both (for this application.)

As to cookies, if the client browser has cookies OFF, would the JS or PHP scripts break ?

If so, please suggest the exception code to handle cookies OFF.

As to JS vs PHP (in this application)... here's the way I see the two scripts operating:

JS --
client sends page request to server
server sends page with ad_JS in it
client runs ad_JS  in the page received  (using client CPU and RAM)
client sets cookie and displays page with ad
done

PHP --
client sends page request to server
server runs ad_PHP in the page requested (using server CPU and RAM)
server sends page with an embedded ad, plus a set-cookie request
client sets cookie and displays page with ad
done

If this is correct, and if we want to minimize server load, wouldn't JS be a better choice in this case ?

I understand that server script is required for certain tasks, such as user validation, email, etc., but for this application, wouldn't JS (i.e. client script) be more appropriate ?

 

by: Tx74Qp853mRPosted on 2008-12-18 at 12:45:54ID: 23207232

Other reasons for using JS instead of PHP:

No changes to the way that files are named and/or processed on the server.  

Embedding PHP into the HTML requires one of the following:
1) files with PHP embedded must be renamed .php -- but doing so breaks external links to those files.
2) the standard Apache pre-processor for .htm, .html and .shtml files must be swapped for the PHP pre-processor.

Doing either of these things, breaks certain HTML directives, such as the include directive.

Embedding JS in HTML doesn't require either of the above... the JS passes directly to the client.  No external links to server files are broken, and no HTML directives are broken in those files.

These factors, in addition to the efficiency factor I mentioned earlier, appear to be compelling reasons for using JS in the ad server.

 

by: b0lsc0ttPosted on 2008-12-18 at 13:33:40ID: 23207688

>> would the JS or PHP scripts break ? <<

I haven't looked closely at the JS code but I doubt it would.  Mplungjan is very thorough and knowledgeable on JS.  The same could be true of Lil so I don't want to discount his contribution.  I just can't say for sure.

The PHP script will not have a problem.  If the cookie isn't there the script will just always show the first ad.  Of course this will make it so your efforts won't work but there won't be an error or "break."  If cookies aren't enabled then you will have a problem no matter what you use.  I mentioned an alternative above but that will definitely need server script and a major change.

Regarding the rest of your posts which you use will need to be your decision.  If this page is static, your site is completely static, and you have no other need for server script then I would stick with Javascript.  It isn't hard to change but there isn't a need to switch to PHP just for this.  However if you are trying to add dynamic features to your site and pages then you should really consider switching to PHP (or other server script) for as much as possible.  Javascript can be disabled or even not supported but server script will work.  In some cases browser support can be different and that can complicate Javascript.

As far as the CPU and RAM "load" for either of these I wouldn't give it a consideration.  If the page was already PHP then adding that little bit is nothing extra to your server.  A few lines of javascript like the ones above also will not "load" the user's computer to any noticeable amount.  In my opinion you would see better improvements for load, etc by making sure you page used valid html, images were optimized, and content efficient.  Those things will make a bigger difference to resource use than the little code we are talking about.

bol

 

by: Tx74Qp853mRPosted on 2008-12-19 at 12:20:48ID: 23215142

mplungjan,

Please say whether your JS breaks when cookies are OFF.

If it does, could you please post the exception code to handle the case when cookies are OFF ?

Thanks for the help.

 

by: b0lsc0ttPosted on 2008-12-19 at 12:23:16ID: 23215167

I'm glad I could help.  Thanks for the fun question, the grade and the points.

bol

 

by: Tx74Qp853mRPosted on 2008-12-19 at 13:57:55ID: 23215845

Cheers,

Tx.

 

by: mplungjanPosted on 2008-12-19 at 23:26:28ID: 23217413

 A good idea to test if cookies are off - here is some code that might do that. Not tested

var idx = getCookie('adIdx')
if (idx == null) {
  setCookie('adIdx',0);// try
  if (getCookie('adIdx')==null) idx = Math.floor(Math.random()*myAds.length); // no cookies
}
else if (idx >= myAds.length) idx = 0;
var myAd = myAds[idx];
setCookie('adIdx',++idx)
                                              
1:
2:
3:
4:
5:
6:
7:
8:

Select allOpen in new window

 

by: Tx74Qp853mRPosted on 2008-12-21 at 12:14:12ID: 23222994

mplungjan,

Thanks again !

 

by: girish2772Posted on 2010-10-13 at 00:50:27ID: 33892223

The above solution helps me If my ad is present on my web sever. But in my case My adv is displayed using a script sent by my client. I have three different script tags for three different ads.  How to integrate these scripts at runtime. I am getting these scripts from db.

 

by: mplungjanPosted on 2010-10-13 at 00:53:31ID: 33892236

can you give use more details and perhaps better: Open a new question?

 

by: girish2772Posted on 2010-10-13 at 04:47:17ID: 33893503

Let me explain in detail.
I have two scripts.
1.
<script type='text/javascript' src='http://4virtu.placelocal.com/_js/ad.js.php?clientID=0&campaignID=5125&adWidth=300&adHeight=250&campaign_api=dispCamp.getNextCampaign&api_url=api.placelocal.com&domain_name=4virtu.placelocal.com&tracking_url=tracking.placelocal.com&tracking_parameters=&animationTime=&clickTag={clickurl}&random={random}'></script>

2.
<script type='text/javascript' src='http://4virtu.placelocal.com/_js/ad.js.php?clientID=0&campaignID=5125&adWidth=728&adHeight=90&campaign_api=dispCamp.getNextCampaign&api_url=api.placelocal.com&domain_name=4virtu.placelocal.com&tracking_url=tracking.placelocal.com&tracking_parameters=&animationTime=&clickTag={clickurl}&random={random}'></script>

If we enter these two scripts at design time into any web page under <div> tag and run we can see that these two scripts are executed. Hence we can see the ads which are running at 'http://4virtu.placelocal.com

Whereas if we try to bind these scripts at runtime to any div then unable to run the scripts. Pl suggest.
My aim is to rotate these two ads.

 

by: mplungjanPosted on 2010-10-13 at 04:51:40ID: 33893541

I would load them in an iFrame

 

by: girish2772Posted on 2010-10-13 at 06:33:51ID: 33894374

id did not work, can pl give me code for this.

 

by: mplungjanPosted on 2010-10-13 at 06:44:33ID: 33894467

this works for me, but does not show an ad because I do not have the correct clientID


<iframe src="about:blank" name="adframe"></iframe>
<script>
window.onload=function() {
  window.adframe.document.write("[<script type='text/javascript' src='http://4virtu.placelocal.com/_js/ad.js.php?clientID=0&campaignID=5125&adWidth=300&adHeight=250&campaign_api=dispCamp.getNextCampaign&api_url=api.placelocal.com&domain_name=4virtu.placelocal.com&tracking_url=tracking.placelocal.com&tracking_parameters=&animationTime=&clickTag={clickurl}&random={random}'><\/script>] ");
  window.adframe.document.close();
}  
</script>

                                              
1:
2:
3:
4:
5:
6:
7:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...