MRW.it Forum
  • Home
  • Forum
  • Fare Web
  • Javascript

Incompatibilità tra javascritp

  • Creatore Discussione Creatore Discussione Mimmo82
  • Data di inizio Data di inizio 18 Ott 2010
M

Mimmo82

Nuovo Utente
5 Set 2010
16
0
1
  • 18 Ott 2010
  • #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"?
 
Devi accedere o registrarti per poter rispondere.

Discussioni simili

C
PHP la funzione COM ed ELAMI, incompatibilità tra tipi.
  • chicone
  • 26 Ott 2011
  • PHP
Risposte
3
Visite
2K
PHP 26 Ott 2011
chicone
C
P
Incompatibilità tra Windows Vista e EasyPHP
  • pepi
  • 1 Ott 2010
  • Windows e Software
Risposte
2
Visite
3K
Windows e Software 1 Ott 2010
pepi
P
H
Problemi incompatibilità sito web con IE
  • Hackx
  • 19 Nov 2014
  • HTML e CSS
Risposte
7
Visite
2K
HTML e CSS 22 Nov 2014
Max 1
P
Slide difettosa x incompatibilità con foglio di stile
  • Paperino78
  • 18 Giu 2013
  • jQuery
Risposte
0
Visite
1K
jQuery 18 Giu 2013
Paperino78
P
M
Incompatibilità browser Firefox – Explorer
  • mariodp
  • 26 Mar 2012
  • PHP
Risposte
12
Visite
3K
PHP 27 Mar 2012
mariodp
M
A
incompatibilità browser joomla
  • alexx
  • 29 Ott 2010
  • Joomla
Risposte
0
Visite
2K
Joomla 29 Ott 2010
alexx
A
P
incompatibilità photoshop CS4 e Google Sketchup 8
  • pepi
  • 14 Ott 2010
  • Photoshop
Risposte
0
Visite
2K
Photoshop 14 Ott 2010
pepi
P
incompatibilità librerie .js?
  • emanuelevt
  • 5 Mar 2010
  • Javascript
Risposte
8
Visite
2K
Javascript 8 Mar 2010
emanuelevt
S
CSS2 ed incompatibilità Internet Explorer (et simila).
  • sergejpinka
  • 13 Gen 2006
  • HTML e CSS
Risposte
1
Visite
1K
HTML e CSS 13 Gen 2006
sergejpinka
S
incompatibilità con firefox1.0.3
  • carla146
  • 25 Apr 2005
  • Supporto Mr.Webmaster
Risposte
3
Visite
2K
Supporto Mr.Webmaster 16 Mag 2005
maxbossi
E
Query differenza tra tabelle
  • Emanuele85
  • 3 Set 2023
  • MySQL
Risposte
5
Visite
2K
MySQL 4 Set 2023
Emanuele85
E
A
differenza tra account email e ISP presenti in blacklist
  • Alby64
  • 18 Mag 2023
  • Posta Elettronica
Risposte
0
Visite
2K
Posta Elettronica 18 Mag 2023
Alby64
A
R
Aprire maschera con Openform filtrando un campo testuale con un valore recuperato da un'altra maschera
  • RAF66
  • 27 Mar 2022
  • MS Access
Risposte
10
Visite
3K
MS Access 3 Apr 2022
RAF66
R
W
Differenza tra orari
  • wolfland
  • 21 Mar 2022
  • PHP
Risposte
3
Visite
1K
PHP 22 Mar 2022
marino51
M
Accodare record presi da un altra tabella
  • Max61
  • 18 Gen 2022
  • PHP
Risposte
8
Visite
2K
PHP 25 Gen 2022
Max61
M
E
Finestra estensioni sparita
  • emanema
  • 14 Gen 2022
  • Photoshop
Risposte
0
Visite
1K
Photoshop 14 Gen 2022
emanema
E
Z
Google Fonts CSS tra desktop e responsive
  • z.cristiano
  • 9 Nov 2021
  • HTML e CSS
Risposte
1
Visite
893
HTML e CSS 18 Nov 2021
jdigital.it
J
Associazioni tra Search Console e Analitycs
  • MarcoGrazia
  • 31 Ago 2021
  • SEO e Posizionamento
Risposte
0
Visite
3K
SEO e Posizionamento 31 Ago 2021
MarcoGrazia
M
Come nascondere la finestra di dialogo di conferma?
  • mikerichards
  • 22 Ago 2021
  • HTML e CSS
Risposte
1
Visite
849
HTML e CSS 22 Ago 2021
Max 1
M
Collegamento tra form html e script php
  • Mollichina
  • 24 Mag 2021
  • PHP
Risposte
4
Visite
2K
PHP 25 Mag 2021
Mollichina
M
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • Javascript
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?