Advertisement:

Author Topic: [SOLVED] Rotating banner at second  (Read 874 times)

HORTENSIA

  • Jr. Member
  • **
  • Posts: 85
[SOLVED] Rotating banner at second
« on: November 09, 2017, 11:01:22 pm »
I would like to insert a php code into the osclass file to run banners at 2/3 second.
Now i have a code but it just runs at refresh... below
You can help with a code please.
.
<?php
$bannerAd[1] = '<a href="" target="_blank"><img title="" src="/reclama/12.png" alt="" width="" height="" />';
$bannerAd[2] = '<a href="" target="_blank"><img title="" src="/reclama/23.png" alt="" width="" height="" />';
$bannerAd[3] = '<a href="" target="_blank"><img title="" src="/reclama/45.png" alt="" width="" height="" />';
$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];
?>
« Last Edit: November 10, 2017, 11:55:51 pm by HORTENSIA »

ayman83

  • Jr. Member
  • **
  • Posts: 82
Re: Rotating banner at second
« Reply #1 on: November 10, 2017, 04:02:08 pm »
Nice idea.
I am waiting for the results.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Rotating banner at second
« Reply #2 on: November 10, 2017, 05:09:53 pm »
Code: [Select]
<script type="text/javascript">

window.onload = function(){

(function(){
  var counter = 0;

  setInterval(function() {
    if (counter %3 ==0) {
      $("#banner").attr("src","/reclama/12.png");
    }
    if (counter %3 ==1) {
      $("#banner").attr("src","/reclama/23.png");
    }
    if (counter %3 ==2) {
      $("#banner").attr("src","/reclama/45.png");
    }
 counter++;

  }, 2500);

})();

}

</script>


<a href="" target="_blank"><img id="banner" src="" /><a>
« Last Edit: November 10, 2017, 05:11:35 pm by marius-ciclistu »

HORTENSIA

  • Jr. Member
  • **
  • Posts: 85
Re: Rotating banner at second
« Reply #3 on: November 10, 2017, 10:09:07 pm »
Thanks code works.
When I open the web site, the ad appears after 2/3 seconds on the site.    --- There is a delay on code?_
When I click on the banner how can I redirect to a page or site.



marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Rotating banner at second
« Reply #4 on: November 10, 2017, 10:24:26 pm »
Yes 
Code: [Select]
}, 2500);

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Rotating banner at second
« Reply #5 on: November 10, 2017, 10:25:56 pm »
EDITED

Code: [Select]
<script type="text/javascript">

window.onload = function(){

(function(){
  var counter = 0;

  setInterval(function() {
    if (counter %3 ==0) {
      $("#banner").attr("src","/reclama/12.png");
      $("#bannerhref").attr("href","link1"); // replace link1
    }
    if (counter %3 ==1) {
      $("#banner").attr("src","/reclama/23.png");
      $("#bannerhref").attr("href","link2"); // replace link2
    }
    if (counter %3 ==2) {
      $("#banner").attr("src","/reclama/45.png");
      $("#bannerhref").attr("href","link3"); // replace link3

    }
 counter++;

  }, 2500);

})();

}

</script>


<a id="bannerhref" href="" target="_blank"><img id="banner" src="" /><a>
« Last Edit: November 10, 2017, 11:42:24 pm by marius-ciclistu »

HORTENSIA

  • Jr. Member
  • **
  • Posts: 85
Re: Rotating banner at second
« Reply #6 on: November 10, 2017, 10:45:25 pm »
I can not write in private.
Nu merge directionarea la clik.  Atunci cand intri de pe google pe site apara greu pe site reclama dupa 3 sec.
« Last Edit: November 10, 2017, 11:56:03 pm by HORTENSIA »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Rotating banner at second
« Reply #7 on: November 10, 2017, 11:34:52 pm »
The images have a certain size I gues that's the delay reason + the script waits for the page to finish loading.

Regarding the href attribute, try entering a full url there, and a valid one.

Edit. I made a mistake. The a href must be changed not the img's:)))

I've edited my above answer.
Sorry.



« Last Edit: November 10, 2017, 11:48:42 pm by marius-ciclistu »

HORTENSIA

  • Jr. Member
  • **
  • Posts: 85
[SOLVED] Re: Rotating banner at second
« Reply #8 on: November 10, 2017, 11:53:11 pm »
It works perfectly
Thank you very much for your help.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: [SOLVED] Rotating banner at second
« Reply #9 on: November 10, 2017, 11:56:24 pm »
 ;)