Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Script banner

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163

    Script banner

    Salve,
    ho scaricato uno script su questo sito che mi gestisce il banner reload (forse è questo il termine, mi scuso...)

    Praticamente questo script mi permette di visualizzare 2 banner che ruotano dopo un tot di tempo, entrambi cliccabili che puntano a 2 indirizzi differenti, pero quando lo vado ad applicare questo scritp nella mia pagina html, mi ributta su una pagina bianca e mi visualizza questo banner che ruota.

    Allego i vari script, se qualcuno puo darmi una dritta...grazie anticipatamente.

    HTML:
    codice:
    		<td width="20%"> 		 		 <script type="text/javascript"> myAd = new Banner( 3, 180, 150, "Clicca", 1, 0 ); myAd.Ad( "ban1.gif", "http://www.google.it", null, "Ciao!" ); myAd.Ad( "ban2.gif", "http://www.ciao.it", null, "Testo" ); myAd.output(); </script> 		 		</td>

    JAVASCRIPT:
    codice:
    function Banner(refreshTime, width, height, altText, start, random){ 	this.objName = "bannerAd" + (Banner.count++); 	eval(this.objName + "=this"); 	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000; 	if (!width) this.width = 180; else this.width = width; 	if (!height) this.height = 150; else this.height = height; 	if (random == null) this.random = 1; else this.random = random; 	this.altText = altText; 	this.ads = []; 	if (start) this.currentAd = start-1; else start = null; 	this.mySize = 0;  	this.Ad = function(src, href, target, mouseover) { 		var tempImage = new Image(); 		tempImage.src = src; 		this.ads[this.mySize] = new Object(); 		var ad = this.ads[this.mySize]; 		ad.src = src; 		if (typeof(target) == "undefined" || target == null) ad.target = "#"; else ad.target = target; 		ad.href = href; 		ad.mouseover = mouseover; 		this.mySize++; 	}  	this.link = function(){ 		var	ad = this.ads[this.currentAd]; 		if (ad.target == "#"){ 			location.href = ad.href; 		} 		else if (ad.target == "_blank" || ad.target == "_new"){ 			open(ad.href,this.objName + "Win"); 		} 		else top.frames[ad.target].location.href = ad.href; 	}  	this.showStatus = function(){ 		var ad = this.ads[this.currentAd]; 		if (ad.mouseover) status = ad.mouseover; 		else status = ad.href; 	}  	this.randomAd = function(){ 		var n; 		do { n = Math.floor(Math.random() * (this.mySize)); }  		while(n == this.currentAd); 		this.currentAd = n; 	}  	this.output = function(){ 		var tempCode = ""; 		if (this.mySize > 1){ 			if (this.currentAd == null) this.randomAd(); 			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1; 			tempCode = ''; 			tempCode += '[img]' + this.ads[this.currentAd].src + '[/img]'; 			document.write(tempCode); 			this.nextAd(); 		} else document.write("Error: two banners must be defined for the script to work."); 	}  	this.newAd = function(){ 		if (!this.random){	 			this.currentAd++; 			if (this.currentAd >= this.mySize) 			   this.currentAd = 0; 		} 		else { 			this.randomAd(); 		} 		this.nextAd(); 	}  	this.nextAd = function(){ 		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src; 		setTimeout(this.objName+'.newAd()',this.refreshTime) 	} }  Banner.count = 0;

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163
    Sbaglio a postare?

    Non ho fatto capire molto?! ...probabile...

  3. #3
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Originariamente inviato da Dom82
    Sbaglio a postare?
    ....
    Sbagli a fare il cross-posting http://forum.html.it/forum/showthrea...1#post13123381
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  4. #4
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    163
    Allora...ho cercato di risolvere il problema come mi è stato suggerito da questo forum (ironicamente, ovvio...) e son riuscito a capire che il problema sta sui javascritp.

    Praticamente io imposto lo sfondo con uno javascript nel body:

    codice:
    <body onload="fixedBackground('sfondo.jpg');">

    con il codice :

    codice:
      var backgroundset=false;  function fixedBackground(url)   {     if(!backgroundset)     {       document.body.style.overflow = 'hidden';       document.body.style.padding  = '0px';       document.body.style.margin   = '0px';        var overlay = document.createElement('DIV');       overlay.style.position    = 'absolute';       overlay.style.top         = '0px';       overlay.style.left        = '0px';       overlay.style.height      = '100%';       overlay.style.width       = '100%';       overlay.style.overflow    = 'auto';        overlay.innerHTML         = document.body.innerHTML;       document.body.innerHTML   = '[img]' + url + '[/img]';        document.body.appendChild(overlay);        backgroundset=true;     }     else       background.src=url;   }


    e proprio questo che mi va in errore, nel senso che se non attivo il JS del banner rotante mi funziona, se lo inseirsco nel caricare la pagina, mi visualizza come già descritto in precedenza (visualizzo il banner su una pagina bianca non vedendo la home).

    Sperando che questa volta qualche anima "pia" mi dia un suggerimento e non una critica...vi lascio un grosso saluto!

    Ciao

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.