/    Sign up×
Community /Pin to ProfileBookmark

Rotating Flash Ads On Refresh

Hello all. Recently came across a script here from another thread for randomly displaying flash banners when a page is refreshed. Here is the code.

[CODE]<html>
<head>
<script type=”text/javascript”>
function switcher()
{
var ad=new Array()

ad[0]=’../../Images/swf/Movie1.swf’;

ad[1]=’../../Images/swf/Movie2.swf’;

ad[2]=’../../Images/swf/Movie3.swf’;

ad[3]=’../../Images/swf/Movie4.swf’;

ad[4]=’../../Images/swf/Movie5.swf’;

var xy=Math.floor(Math.random()*ad.length);

document.getElementById(‘iframe1’).src=ad[xy];
}
</script>
</head>
<body onLoad=”switcher()”>
<iframe name=”iframe1″ id=”iframe1″ src=”” width=”453″ height=”52″ scrolling=”no” frameborder=”0″>Click Here!</iframe>
<br>
</body>
</html>[/CODE]

The code works great but the problem i’m having is A) the two flash ads i want to display are not the same size and ? the client wants to be able to track the number of times their ads load, (i’m pulling the flash ads from their server) and i don’t believe displaying it through an iframe can provide them the ability to track the number of loads.

If anyone here could provide a work around for these two issues I would really appreciate it!!!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@chadillacJun 30.2006 — you need a server side language with database support my friend. This way you can store all the flash attributes in a table, or in a complex array, such as width, height, file path. Then upon display of that one you can have it update the "displayCount" field of your table in the database.

this would be a pretty easy script to setup, I suggest you look into some simple PHP and mySQL tutorials ?


if you absolutely positively must have to not doubt about gotta use javascript... you could always, as I mentioned above create an array per-ad... each array containing height, width, & file path. upon picking an ad have it update the embed tag attributes... as far as counting the number of times to display... well I would suggest a text file on the server, but javascript can't update those.. you could I suppose use ajax and update a DB... but if you are going to go into that kind of trouble you should just do the server side solution from the get go.
×

Success!

Help @SumOne spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...