Incompatibilità tra javascritp

Mimmo82

Nuovo Utente
5 Set 2010
16
0
1
Ciao a tutti...

premetto che son abbastanza ignorante di questi linguaggi di programmazione ma la passione e la voglia mi anima ad andare avanti...

cosi realizzando il mio sito, avevo bisogno di far ruotare un banner lincabile (cioè 2 immagini lincate a 2 siti diversi, che ruotano ogni 10 secondi).

Bene, questo JS mi da un problema anomalo, praticamente quando lo eseguo sulla mia pagina index, in una frazione di tempo che visualizzo la pagina subito mi ributta su una pagina bianca con questo banner che inizia a ruotare.
Facendo un po di prove in lungo e in largo, ho notato che se tolgo il JS che mi carico un immagine di sfondo, il fenomeno su elencato non si verifica.STRANO...

Allora lo sfondo lo carico cosi :

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

Mentre il banenr ruotante ha il seguente JS:

HTML:
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 = "_self"; else ad.target = target;
        ad.href = href;
        ad.mouseover = mouseover;
        this.mySize++;
    }

    this.link = function(){
        var    ad = this.ads[this.currentAd];
        if (ad.target == "_self"){
            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 = '<a href="javascript:'+this.objName+'.link();"';
            tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
            tempCode += ' onMouseOut="status=\'\';return true">';
            tempCode += '<img src="' + this.ads[this.currentAd].src + '" width="' + this.width;
            tempCode += '" name="' + this.objName + 'Img" height="' + this.height + '" ';
            if (this.altText) tempCode += 'alt="'+this.altText + '" ';
            tempCode += 'border="0" /></a>';
            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;

e lo richiamo cosi :

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

</script>

Come è possibile che son incompatibili 2 js?Anche perche quello script per il banner rotante mi serve per altri 7 spazi illustrativi di foto...

Qualcuno ha avuto la mia stessa "dis-avventura"?
 
Discussioni simili
Autore Titolo Forum Risposte Data
C PHP la funzione COM ed ELAMI, incompatibilità tra tipi. PHP 3
P Incompatibilità tra Windows Vista e EasyPHP Windows e Software 2
H Problemi incompatibilità sito web con IE HTML e CSS 7
P Slide difettosa x incompatibilità con foglio di stile jQuery 0
M Incompatibilità browser Firefox – Explorer PHP 12
A incompatibilità browser joomla Joomla 0
P incompatibilità photoshop CS4 e Google Sketchup 8 Photoshop 0
emanuelevt incompatibilità librerie .js? Javascript 8
S CSS2 ed incompatibilità Internet Explorer (et simila). HTML e CSS 1
carla146 incompatibilità con firefox1.0.3 Supporto Mr.Webmaster 3
E Query differenza tra tabelle MySQL 5
A differenza tra account email e ISP presenti in blacklist Posta Elettronica 0
W Differenza tra orari PHP 3
Z Google Fonts CSS tra desktop e responsive HTML e CSS 1
MarcoGrazia Associazioni tra Search Console e Analitycs SEO e Posizionamento 0
M Collegamento tra form html e script php PHP 4
D popolare campi tra th alla select PHP 36
Gabriele Visioli Differenza tra hosting e hosting WordPress Hosting 4
S Differenza tra le funzioni include () e require ()? PHP 1
P Ciclare tra array di oggetti PHP 1
B Incongruenze tra Mac ver e PC ver Photoshop 1
N Problema passaggio variabili tra pagine PHP 4
L estrarre valori max tra più tabelle MySQL 2
MarcoGrazia Dati nulli su join tra più tabelle MySQL 1
S Utilizzo variabili di sessione tra PC e server PHP 0
R Relazione tra tabelle MS Access 5
Tommy03 Query tra 3 tabelle MySQL 2
elpirata [MySQL] Sincronizzare dati tra due tabelle sullo stesso host MySQL 0
R passaggio variabili tra modulo genitore a figlio jQuery 3
P Passagio dati complessi tra una ASP.NET webapi e Angular ASP.NET 1
A [ASP] Confronto tra dati Form e DB Classic ASP 2
G [PHP] Passare dati tra record PHP 4
M [MS Access] Relazione tra maschere MS Access 1
T onsiglio Web agency tra Caserta Agro Aversano e Napoli e zone vicine. Offerte e Richieste di Lavoro e/o Collaborazione 0
D Jquery, conflitto tra loro risolvibile? jQuery 7
J Passaggio variabile tra 2 file php PHP 15
E Compro profilo Instagram tra 10k e 30k Annunci servizi di Social Media Marketing 2
U [PHP] Differenza tra amministratore e utente PHP 2
P [PHP] Spostamento tra cartelle PHP 2
F [Javascript] Conflitto tra più form nella stessa pagina Javascript 1
M PHP Arrotondamento minuti in differenza tra due Orari PHP 9
felino EXCEL: verifica dati mancanti tra due sheet Windows e Software 2
K [PHP] Controllare dati database tra due valori PHP 18
K [PHP] Collegamento tra più tabelle PHP 10
M [HTML] problema spazio aggiuntivo tra elementi <li> di menu a tendina HTML e CSS 1
gandalf1959 problema con la codifica caratteri accentati e speciali tra php e mysql PHP 3
Z [Javascript] TINYMCE tra &RSQUO e &QUOTE Javascript 2
kiai969 Link tra 3 siti miei SEO e Posizionamento 2
S [Javascript] [CSS] Spazio Bianco tra Slider e Menu foto Javascript 6
G [PHP] operazione matematica tra risultati di query PHP 5

Discussioni simili