TinyPortal

Development => Block Codes => Topic started by: phpshiva on November 12, 2008, 03:55:55 PM

Title: sliding banners
Post by: phpshiva on November 12, 2008, 03:55:55 PM
You can put this in a scriptbox
To use for banners or affiliate ads

Demo (http://www.phpshiva.nl/)

<script language="JavaScript1.2">

//you can alter the width here  (in pixels)
var sliderwidth=600
//you can alter the heigt here (in pixels )
var sliderheight=100
//you can alter the seed here (higher is faster)
var slidespeed=4


var leftrightslide=new Array()
var finalslide=''
// alter below your url's (a href ) and the pictures (img scr )
leftrightslide[0]='<a href="http://www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60"  border=0></a>'
leftrightslide[1]='<a href="www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60" border=0></a>'
leftrightslide[2]='<a href="www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60" border=0></a>'
leftrightslide[3]='<a href="www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60" border=0></a>'
///////Dont alter below////////////////////////////////////

var copyspeed=slidespeed

for (i=0;i<leftrightslide.length;i++)
finalslide=finalslide+leftrightslide[i]+"  "


if (document.all){
document.write('<marquee id="ieslider" scrollAmount=0 style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
ieslider.onmouseout=new Function("if (document.readyState=='complete') ieslider.scrollAmount=slidespeed")
}

function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers){
document.ns_slider01.visibility="show"
setTimeout("window.onresize=regenerate",450)
intializeleftrightslide()
}
if (document.all)
ieslider.scrollAmount=slidespeed
}

function intializeleftrightslide(){
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
document. ns_slider01.document.ns_slider02.document.close()
thelength=document.ns_slider01.document.ns_slider02.document.width
scrollslide()
}

function scrollslide(){
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
document.ns_slider01.document.ns_slider02.left-=slidespeed
setTimeout("scrollslide()",100)
}
else{
document.ns_slider01.document.ns_slider02.left=sliderwidth
scrollslide()
}
}
window.onload=regenerate2

//-->
</script>


<ilayer width=&{sliderwidth}; height=&{sliderheight}; name="ns_slider01" visibility=hide>
<layer name="ns_slider02" onMouseover="slidespeed=0;" onMouseout="slidespeed=copyspeed"></layer>
</ilayer>



this will slide your banners from right to left .
and its easy to put more banner in it
Title: Re: sliding banners
Post by: G6Cad on November 12, 2008, 04:05:07 PM
Please repost your code, and this time, in code tags as the code render wrongly with out it.
Also, i will move this to the proper board.
Title: Re: sliding banners
Post by: phpshiva on November 13, 2008, 06:40:34 AM
Sorry for that G6

Did the tags now

Title: Re: sliding banners
Post by: G6Cad on November 13, 2008, 07:21:58 AM
Thank you  :up:
Title: Re: sliding banners
Post by: Bluto on November 15, 2008, 12:24:52 AM
Looks great ! I can't understand the top that is commented out. Doest that part matter?
Or could someone translate?
Title: Re: sliding banners
Post by: phpshiva on November 15, 2008, 07:30:27 AM
there is nothing comment out
i translated the code for you

have fun
Title: Re: sliding banners
Post by: SmokyBlue on November 15, 2008, 12:50:42 PM


you did a great job, thanks for sharing, phpshiva :D
Title: Re: sliding banners
Post by: Bluto on November 15, 2008, 01:00:24 PM
Thank you. Looks very useful.
Title: Re: sliding banners
Post by: phpshiva on November 15, 2008, 02:53:37 PM
Your welcom


you can add more banners like this
leftrightslide[4]='<a href="www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60" border=0></a>'
leftrightslide[5]='<a href="www.yoursite.com"><img src="http://www.yoursite.com/bannerhere" width="468" height="60" border=0></a>'



Greetz phpshiva
Title: Re: sliding banners
Post by: Bluto on November 15, 2008, 03:01:48 PM
Thanks. I think I will use this for featured affiliates. The ones that deserve the big banners.
Edit: I think I might add an "alt" tag in there to make the spiders happy as well as people with slow connections.
Title: Re: sliding banners
Post by: NOBLE CANADIAN on November 16, 2008, 06:15:11 AM
Hello, :)

I tried inputting this code into a scriptbox, but the result is just an empty box. The only code that I edited was the URL specification area.

I'm currently using SMF 1.1.7 and TinyPortal v1.0.5 beta 1.
Title: Re: sliding banners
Post by: phpshiva on November 16, 2008, 09:12:06 AM
iff you did it ok than i should show try to look if you left out something in the code
just try to copy code again and alter url again.
Title: Re: sliding banners
Post by: NOBLE CANADIAN on November 16, 2008, 07:24:07 PM
Well I gave it another try, but the same result occurs no matter what I do. I have one other scriptbox that's running my Slideshow, which is operating perfectly.

In case you're wondering, I'm using Firefox 3.
Title: Re: sliding banners
Post by: phpshiva on November 16, 2008, 07:33:22 PM
do you see the demo on my site? if that is working than yours works to
Title: Re: sliding banners
Post by: Bluto on November 16, 2008, 07:44:55 PM
No go here either. I added just 1 url with an image link, I commented out the rest of the links.
The block shows, but there is no height to it. You can see it here on top, above the news box.
http://www.sbmtrader.com/index.php (http://www.sbmtrader.com/index.php)
Edit. I also changed the default image dimensions to fit the size of my image.
Title: Re: sliding banners
Post by: SmokyBlue on November 16, 2008, 08:08:24 PM
this is what i am finding on your site phpshiva..
Title: Re: sliding banners
Post by: NOBLE CANADIAN on November 16, 2008, 08:11:02 PM
Ok, the problem is that this snippet has a browser incompatibility issue. I just checked it using Internet Explorer 7 and everything seems fine. This snippet won't do much good until it's Firefox 3 friendly as well.