473,893 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cycling Banners and Clickable Links

10 New Member
I am working with javascript...wh ere I have cycling banners at the top, 3 of them and I need to make two of them clickable to a website that I assign to the two. bannerad2 for www.bigmtn.com and bannerad3 for www.bridgerbowl .com Not sure how to get this to work right, have tried some things and it usually ends up making duplicate banners above the original, which I don't want. Here is some of the code for now:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>Ski Montana</title>
  4. <SCRIPT LANGUAGE="JAVASCRIPT">
  5. <!-- Hide from old browers
  6.  
  7.     var banners = new Array("bannerad1.jpg","bannerad2.jpg","bannerad3.jpg")  
  8.     var bnrCntr = 0
  9.     function bancycle() {
  10.          bnrCntr = bnrCntr + 1
  11.          if (bnrCntr == 3) {
  12.          bnrCntr = 0
  13.          }
  14.          document.Bannerad.src = banners[bnrCntr]
  15.          setTimeout("bancycle()",3000)
  16.     }
  17.  
  18. //-->
  19. </SCRIPT>     
  20. </head>
  21. <body bgcolor="WHITE" onload="setTimeout('bancycle()',3000)">
  22.  
  23. </body>
  24. </html>
Feb 3 '09 #1
3 3465
ivosilva
17 New Member
Hi, jock1up!

Here's a working code to achieve what you want:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.  
  5.     <title>Ski Montana</title>
  6.  
  7.     <script type="text/javascript">
  8.  
  9.         var banner1 = {src: 'bannerad1.jpg', url: ''};
  10.         var banner2 = {src: 'bannerad2.jpg', url: 'http://bytes.com'};
  11.         var banner3 = {src: 'bannerad3.jpg', url: 'http://www.google.com'};
  12.  
  13.         var banners = new Array(banner1, banner2, banner3);
  14.  
  15.         var bnrCntr = 0;
  16.  
  17.         function bancycle() {
  18.  
  19.             bnrCntr = bnrCntr + 1;
  20.  
  21.             if (bnrCntr == 3) bnrCntr = 0;
  22.  
  23.             var ban = document.getElementById('banner');
  24.  
  25.             ban.src = banners[bnrCntr].src;
  26.  
  27.             if(banners[bnrCntr].url.length > 0) {
  28.                 ban.style.cursor = 'pointer';
  29.                 ban.onclick = function() {
  30.                     window.location.href = banners[bnrCntr].url;
  31.                 }
  32.             } else {
  33.                 ban.style.cursor = 'default';
  34.                 ban.onclick = function(){};
  35.             }
  36.  
  37.             setTimeout(bancycle, 3000);
  38.         }
  39.  
  40.     </script>
  41.  
  42. </head>
  43. <body onload="setTimeout(bancycle, 3000);">
  44.  
  45.     <img id="banner" src="bannerad1.jpg" />
  46.  
  47. </body>
  48. </html>
  49.  
Hope it helps.

Best regards!
Feb 4 '09 #2
jock1up
10 New Member
Thanks! I did try this and the links do work...only problem is that instead of the original banner doing this...it is still there, which doesn't cycle now...and the new one is above it so I have a duplicate banner. I need one that does this...hopefull y in the original spot.


Here is more code further down...if that helps, couldn't put it all on here at once! The bold area is what references the existing banner that I had on the page. Thanks 4 the help so far...it's getting there!

Expand|Select|Wrap|Line Numbers
  1. <body>
  2.  
  3. <table cellspacing="0" cellpadding="0" border="0">
  4.   <tr>
  5.     <td width="15" height="6" valign="top"></td>
  6.     <td width="103" height="6" valign="top"></td>
  7.     <td width="10" height="6" valign="top"></td>
  8.     <td width="9" height="6" valign="top"></td>
  9.     <td width="176" height="6" valign="top"></td>
  10.     <td width="1" height="6" valign="top"></td>
  11.     <td width="96" height="6" valign="top"></td>
  12.     <td width="1" height="6" valign="top"></td>
  13.     <td width="209" height="6" valign="top"></td>
  14.     <td width="11" height="6" valign="top"></td>
  15.     <td width="6" height="6" valign="top"></td>
  16.     <td width="133" height="6" valign="top"></td>
  17.   </tr>
  18.   <tr>
  19.     <td width="15" height="89" valign="top"></td>
  20.     <td width="103" height="89" valign="top"></td>
  21.     <td width="10" height="89" valign="top"></td>
  22.     <td width="503" height="89" colspan="7" valign="top"><img src="bannerad1.jpg" Name="Bannerad" width="503" height="68"></td>
  23.     <td width="6" height="89" valign="top"></td>
  24.     <td width="133" height="89" valign="top"></td>
  25.   </tr>
Feb 4 '09 #3
ivosilva
17 New Member
Hi, jock1up!

I'm not understanding what problem you're having. What do you mean by duplicate banner?

If you try the exact code I sent the banners cycle well and the links work fine on the two last banners.

It would help if I could check the exact Javascript that you are using (I can see that your image does not have an "id" attribute, has in the code I pasted so I guess you're using a customized version).

Best regards!
Feb 4 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1180
by: Showjumper | last post by:
I have seen the article on 4 guys that descibes creating an event calandar. However what i would like to do is have the days be clickable (i.e. click the day and it show the details for that event) only if there is an event on that day while other days are not clickable if there is no event. I have see the post on scottonwriting about customizing the calendar to get ti to have clickable days for .text. But i havent been able to modify this...
1
3071
by: Adrian | last post by:
Hi All I have some text that I want to parse and display in such a way that a user can click on different bits and depending what the click on call the relevant sub. is the Rich Text Box the correct control for this? if so how would I do it? if not what should I be using? example:
1
1303
by: Jimmy | last post by:
In the asp.net application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code is supplied from 3rd parties and may display banners, links and do various other things. So far so good. What I need is to track the clicks for each such banner in a generic way. That is, whatever JS provided has to run inside some control (or...
1
1661
by: Jimmy | last post by:
In the web application I develop, we need to provide the marketing department with the ability to insert small JavaScript code snippets into predefined content areas on several pages. This code is supplied from 3rd parties and may display banners, links and do various other things. So far so good. What I need is to track the clicks for each such banner in a generic way. That is, some javascript or server-side technique that will allow...
2
2074
by: Krustov | last post by:
The question of how to create thumbnails with clickable links gets asked on this newsgroup every so often - like clock work . Just really posing this script here for google to archive it & so users can be pointed to it in the future via a link to google groups . <html> <head>
3
5464
by: Irocivan | last post by:
Hello, I download a nice collapse menu for free distribution from the internet. It works very well except that none of the parents nodes are clickable (i.e. when clicking on the parent node, the link does not work). For example, if the below content is included in the html page, I would like that page www.fruit.com can be loaded whenever I click it. However the javascript does not allow the page to be loaded, It would only work for the child...
7
2647
by: Jeff Gaines | last post by:
I have spent the day learning how to use Zend Development Environment. I can now produce a list of files in a directory, filtered by extension, and apparently clickable. Unfortunately clicking on them in a browser doesn't take me to the file link. I have found examples for clickable URL's, FTP links and mailto addresses but not files. I am managing to produce output like this: <a...
3
2190
by: breakupemail | last post by:
Hello, on my website at http://www.breakupemail.com/ there is a horizontal navigation bar with 6 hyperlinks. Recently, I added a second navigation row below the first, with 2 links. Once this second navigation bar was added, the clickable area on the 6 links in the top row became greatly reduced when viewed in Firefox 2.0.0.9. It seems to work properly in IE 7. Essentially, if you hold your mouse over the center of the text link, it will...
2
7074
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so the entire block is clickable, not just the text. I've sorta got it so it's clickable, just some parts of the button I still can't click on. The website is http://pdhtdev.johnabbott.qc.ca/students/2010/james_mann/portfolio/index.htm The css...
0
9830
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
10837
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
10927
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
10469
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
9645
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...
1
8021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7173
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4684
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.