473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rotating Banner Question

I'm trying to complete a rotating banner ad within a page I have. The
rotating add has four images that rotate in three-second increments.
I've got the images to rotate ok - but now I want to go one step
further and can't figure out how to do it...

I want to have it so that when the person clicks on the specific ad,
they are taken to a URL that is unique to each ad.

I presume I would have to surround the img tag with an href tag, but
how would I reference the array to get the correct URL?? HELP.

Here is the code I'm using. Any help would be appreciated.

I've omitted unnecessary parts of the page.

-----------------------------------------------
<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner01.jpg", "images/banner02.jpg",
"images/banner03.jpg", "images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}
</script>
</head>
<body onLoad="rotate( );">
<div align="center">
<img src="images/banner01.jpg" name="adBanner"/></div>
</body>
Jul 20 '05 #1
4 2405

Ian Hubling <ia*@hubling.co m> wrote in message
news:nj******** *************** *********@4ax.c om...
I'm trying to complete a rotating banner ad within a page I have. The
rotating add has four images that rotate in three-second increments.
I've got the images to rotate ok - but now I want to go one step
further and can't figure out how to do it...

I want to have it so that when the person clicks on the specific ad,
they are taken to a URL that is unique to each ad.

I presume I would have to surround the img tag with an href tag, but
how would I reference the array to get the correct URL?? HELP.

Here is the code I'm using. Any help would be appreciated.

I've omitted unnecessary parts of the page.

-----------------------------------------------
<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner01.jpg", "images/banner02.jpg",
"images/banner03.jpg", "images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}
</script>
</head>
<body onLoad="rotate( );">
<div align="center">
<img src="images/banner01.jpg" name="adBanner"/></div>
</body>


Hi,
one suggestion would be to create a URL array of corresponding destinations
and
add an onclick handler to the image which uses the array and thisAd to open
the
appropriate destination.

myURL=new Array( "url1", url2", url3", url4");

function newWindow()
{
// alert( "you clicked " + thisAd);
window.open( myURL[thisAd]); // or a redirect
}

and

<img src="hook1.jpg" name="adBanner"/ onclick="newWin dow();"></div>

Jul 20 '05 #2
On Sun, 08 Feb 2004 19:19:09 GMT, "Chris Crandell"
<cc******@ix.ne tcom.com> wrote:

Ian Hubling <ia*@hubling.co m> wrote in message
news:nj******* *************** **********@4ax. com...
I'm trying to complete a rotating banner ad within a page I have. The
rotating add has four images that rotate in three-second increments.
I've got the images to rotate ok - but now I want to go one step
further and can't figure out how to do it...

I want to have it so that when the person clicks on the specific ad,
they are taken to a URL that is unique to each ad.

I presume I would have to surround the img tag with an href tag, but
how would I reference the array to get the correct URL?? HELP.

Here is the code I'm using. Any help would be appreciated.

I've omitted unnecessary parts of the page.

-----------------------------------------------
<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner01.jpg", "images/banner02.jpg",
"images/banner03.jpg", "images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}
</script>
</head>
<body onLoad="rotate( );">
<div align="center">
<img src="images/banner01.jpg" name="adBanner"/></div>
</body>


Hi,
one suggestion would be to create a URL array of corresponding destinations
and
add an onclick handler to the image which uses the array and thisAd to open
the
appropriate destination.

myURL=new Array( "url1", url2", url3", url4");

function newWindow()
{
// alert( "you clicked " + thisAd);
window.open( myURL[thisAd]); // or a redirect
}

and

<img src="hook1.jpg" name="adBanner"/ onclick="newWin dow();"></div>

Thank you very much! I modified it slightly from your response - but
you gave me exactly what I was looking for. Here's the script I ended
up with. Works like a charm!

//-------------------------------------------------------

<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner02.jpg", "images/banner03.jpg",
"images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}

myURL=new Array("url1.htm ", "url2.htm","url 3.htm");
function vgotoad()
{
window.location .href(myURL[thisAd]);
}
</script>
</head>

<body onLoad="rotate( );">

<div align="center"> <img src="images/banner01.jpg" name="adBanner"
onClick="vgotoa d();"></div>
</body>

Jul 20 '05 #3

Ian Hubling <ia*@hubling.co m> wrote in message
news:qo******** *************** *********@4ax.c om...
On Sun, 08 Feb 2004 19:19:09 GMT, "Chris Crandell"
<cc******@ix.ne tcom.com> wrote:

Ian Hubling <ia*@hubling.co m> wrote in message
news:nj******* *************** **********@4ax. com...
I'm trying to complete a rotating banner ad within a page I have. The
rotating add has four images that rotate in three-second increments.
I've got the images to rotate ok - but now I want to go one step
further and can't figure out how to do it...

I want to have it so that when the person clicks on the specific ad,
they are taken to a URL that is unique to each ad.

I presume I would have to surround the img tag with an href tag, but
how would I reference the array to get the correct URL?? HELP.

Here is the code I'm using. Any help would be appreciated.

I've omitted unnecessary parts of the page.

-----------------------------------------------
<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner01.jpg", "images/banner02.jpg",
"images/banner03.jpg", "images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}
</script>
</head>
<body onLoad="rotate( );">
<div align="center">
<img src="images/banner01.jpg" name="adBanner"/></div>
</body>


Hi,
one suggestion would be to create a URL array of corresponding destinationsand
add an onclick handler to the image which uses the array and thisAd to openthe
appropriate destination.

myURL=new Array( "url1", url2", url3", url4");

function newWindow()
{
// alert( "you clicked " + thisAd);
window.open( myURL[thisAd]); // or a redirect
}

and

<img src="hook1.jpg" name="adBanner"/ onclick="newWin dow();"></div>

Thank you very much! I modified it slightly from your response - but
you gave me exactly what I was looking for. Here's the script I ended
up with. Works like a charm!

//-------------------------------------------------------

<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner02.jpg", "images/banner03.jpg",
"images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}

myURL=new Array("url1.htm ", "url2.htm","url 3.htm");
function vgotoad()
{
window.location .href(myURL[thisAd]);
}
</script>
</head>

<body onLoad="rotate( );">

<div align="center"> <img src="images/banner01.jpg" name="adBanner"
onClick="vgotoa d();"></div>
</body>


Glad I could help !

Jul 20 '05 #4
EMC

Hi -
Yes I agree very helpful. Two quick follow-up, questions. How woul
you add the cursor switch, that is when I mouse over (the rotatin
images), the cursor does not switch to a hand (for example). I trie
adding style cursor auto line in the body tag , to no avail. Secon
question, this works fine in newer versions of Mozilla and Netscap
(6.x ->) but nothing happens in say Netscape 4.7x. No JS error
nothing. Any ideas here.
Thanks a bunch -
EMC

Chris Crandell wrote:
*Ian Hubling <ia*@hubling.co m> wrote in message
news:qo******** *************** *********@4ax.c om...
On Sun, 08 Feb 2004 19:19:09 GMT, "Chris Crandell"
<cc******@ix.ne tcom.com> wrote:
destinations open
Thank you very much! I modified it slightly from your response

but
you gave me exactly what I was looking for. Here's the script

ended
up with. Works like a charm!

//-------------------------------------------------------

<head>
<script>
var myPix, imCt, thisAd;
myPix=new Array("images/banner02.jpg", "images/banner03.jpg",
"images/banner04.jpg");
imgCt=myPix.len gth;
var thisAd=0;
function rotate()
{
thisAd++
if(thisAd==imgC t)
{
thisAd=0;
}
document.adBann er.src=myPix[thisAd];
setTimeout("rot ate()",3*1000);
}

myURL=new Array("url1.htm ", "url2.htm","url 3.htm");
function vgotoad()
{
window.location .href(myURL[thisAd]);
}
</script>
</head>

<body onLoad="rotate( );">

<div align="center"> <img src="images/banner01.jpg" name="adBanner"
onClick="vgotoa d();"></div>
</body>


Glad I could help !

-
EM

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2104
by: Grunt | last post by:
Hi, I have been trying to put together a rotating banner. the code works but I am having a problem with the caching of the banner images. no matter what I try the page is constantly reloading the images, even worse they are not loading completely. This version includes a (vain) attempt at forcing the banner images to cache. Apart form the caching problem the scripting seems to work Any help welcomed:
2
2009
by: mikeoley | last post by:
Ok what I'm trying to do should be fairly simple. I have an image on a page that rotates with 4 other images. All I want to do is be able to link this images to different parts of the site when the user clicks on them. I can't figure out how to add the "HREF" tag in there to make it work though. It's the bottom left image that rotates. Thanks for any help or advice <a href="http://www.eg-designdev.com/aircylinders/index3.jsp">Air
8
7860
by: Neil Robbins | last post by:
I have created a setup project using the setup wizard and am now editing the properties of this project. I want to replace the default banner with one of my own. Could someone tell me what the dimensions of the banner should be (in pixels preferably). I can do a rough match, but I'd rather things were a bit more perfect. As always any help would be greatly appreciated. Neil R
4
1962
by: Patrick Rouse | last post by:
Please point me to the correct newsgroup if this is the wrong place to post this question. My website is written in simple HTML and hosted on a windows server at secureserver.net (via GoDaddy). I use an ASP Web Stats program called Power-Stats to track my website traffic, search keywords... The data is stored in an Access Database hosted on my website. I'd like to be able to track how many clicks I get on each of my banner ads,...
3
2310
by: | last post by:
I want a banner to appear at the bottom of each page of a web app. I created a user control that describes the banner and have it placed in all my pages. For the most part it functions as needed. The exception is when the content of the web page is longer than the screen. The user has to scroll for the full content, but the bottom banner still appears at the bottom of the screen, so it appears across the main body content on small...
2
2820
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is, rotates banners with hyperlink specific to each image. it works just perfect but i need a simple modification. now I want to stop rotating the images when I mouseover on the image, and then continue once I move the cursor out of the banner image....
3
5953
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In fact I still hesitate between java and javascript. My question is how can I create a interacting globe using a satellite photo. This is a very usefull applet for everybody. All suggestion welcome! Thanks Arnaud
1
1814
by: kennykenn | last post by:
Im having trouble startin to develop a rotating image banner, I have coded part of it (only pulling image from a db). My aim is to print an image to part of my web page, allow it to screen for x amout of time and then i need a function to show the image dissolving, flipping or an effect similar to then appear with the next image and so on. Could ne1 help?!?
1
2565
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in mediasurface My code is: <!-- start page container --> <div id="pageContainer"> <!-- start middle content area --> <div id="genericMiddle">
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.