dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Rotating Advertisement Banner Help

  1. #1
    Join Date
    Jun 2010
    Location
    Ontario, Canada
    Posts
    4

    Rotating Advertisement Banner Help

    I am wanting to make a rotating banner using Javascript. This is intended to have advertisements on my website which have an image with a clickable link and changes every 5 seconds. I would like the banner to be 728x90. I would like to have the image and link files in the javascript file so if it needs to be modified, it can be easily without going through 100 html pages. So far this is what I have but am still having some issues. I pulled this code from another forum on an older post and am a little unsure what parts to fill out. I just filled in the http links as an example, I was just using pages from my site original for a test run. The images on the other hand, that is the source to the files. The image does not want to show up, however there is a box. And when I click on the box, it says no file exists at that address...

    HTML
    Code:
    <a id="ad-link" href="url to advertisements homepage" >
        <img class="advertisement" id="ad-img" src="url to image">
    </a>
    JS
    Code:
    document.getElementById("ad-link").setAttribute("href", "http://advertisementspaceforrent1, http://advertisementspaceforrent2");
    document.getElementById("ad-img").setAttribute("src", "images/advertisementspaceforrent1.png, images/advertisementspaceforrent1.png");
    setTimeout(function() {
        //update banner
    }, 5000);
    CSS
    Code:
    .advertisement {
    	height: 90px;
    	width: 728px;
    	float: center;
    }

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    3,630
    JQuery as you will see is answered in a sub forum to this JavaScript forum, see my sig for a link.
    --> JavaScript Frameworks like JQuery, Angular, Node <-- ... and please remember to wrap any code you have in forum tags:-
    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Sep 2015
    Posts
    95
    I don't think you're suppose to have two urls when you set the href attribute and the src attribute.

    Should be more like this:
    Code:
    document.getElementById("ad-link").setAttribute("href", "http://advertisementspaceforrent1");
    document.getElementById("ad-img").setAttribute("src", "images/advertisementspaceforrent1.png");

  4. #4
    Join Date
    Dec 2015
    Posts
    87
    Hello friend,
    You can use js setinterval to repeat the event of clicking the thumbnails.

    http://jsfiddle.net/L7yKp/99/

    HTML

    <input type="checkbox" name="autoplay" value="autoplay" />autoplay

    JS

    function autoPlay() {
    var nextImg = $('#thumbs>img.clicked').next();
    if (nextImg.length == 0) {
    nextImg = $('#thumbs>img').eq(0);
    }
    nextImg.click();
    }
    var autoInterval;
    $('input[type="checkbox"][name="autoplay"]').click(function () {
    if ($(this).is(":checked")) {
    autoInterval = setInterval(autoPlay, 2000);
    } else {
    clearInterval(autoInterval);
    }
    });
    Try this code or just go through" http://www.htmlgoodies.com/beyond/ja...r-Web-Site.htm ".
    Good Luck.

  5. #5
    I am wanting to make a rotating banner using Javascript. This is intended to have advertisements on my website which have an image with a clickable link and changes every 5 seconds. I would like the banner to be 728x90. I would like to have the image and link files in the javascript file so if it needs to be modified, it can be easily without going through 100 html pages. So far this is what I have but am still having some issues. I pulled this code from another forum on an older post and am a little unsure what parts to fill out. I just filled in the http links as an example, I was just using pages from my site original for a test run. The images on the other hand, that is the source to the files. The image does not want to show up, however there is a box. And when I click on the box, it says no file exists at that address

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles