Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Incompatibilità tra javascritp

Incompatibilità tra javascritp

Pianificato Fissato Bloccato Spostato Coding
2 Post 2 Autori 588 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • M
    M
    mimmo82
    scritto su ultima modifica di
    User Attivo 0
    #1
    Incompatibilità tra javascritp

    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 :

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

    con IL JS:

     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 id="background" height="100%"  width="100%" src="' + url + '" style="left: 0; bottom: 0; right: 0; top: 0; z-index: 0" />';        document.body.appendChild(overlay);        backgroundset=true;     }     else       background.src=url;   }
    

    Mentre il banenr ruotante ha il seguente JS:

    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 :

    <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"?

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • A
      A
      ayrton2001
      scritto su ultima modifica di
      Super User 20
      #2

      Ciao Mimmo82,
      a me funziona. Vedo lo sfondo ed i banner che girano.
      Per cercare di replicare l'errore ho creato questa pagina (ho modificato il nome delle immagini):

      <html>
      <head>
      <script type="text/javascript">
      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 id="background" height="100%"  width="100%" src="' +  url + '" style="left: 0; bottom: 0; right: 0; top: 0; z-index: 0" />';        document.body.appendChild(overlay);        backgroundset=true;     }     else       background.src=url;   }
      
      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;
      </script>
      <script type="text/javascript">
      myAd = new Banner( 3, 180, 150, "Clicca", 1, 0 );
      myAd.Ad( "down.png", "google.it", null, "Ciao!" );
      myAd.Ad( "up.png", "ciao.it", null, "Testo" );
      myAd.output();
      
      </script>
      </head>
      <body onload="fixedBackground('sfondo.jpg');">
      
      </body>
      </html>
      
      1 Risposta Ultima Risposta
      Miglior risposta 0
      0

      Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

      Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

      Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

      Registrati Accedi
      Rispondi
      • Risposta alla discussione
      Effettua l'accesso per rispondere
      • Da Vecchi a Nuovi
      • Da Nuovi a Vecchi
      • Più Voti


      • Accedi

      • Non hai un account? Registrati

      • Accedi o registrati per effettuare la ricerca.
      • Primo post
        Ultimo post
      Home Accedi Registrati
      Menu
      • CATEGORIES
      • La Community Connect.gt
      • Presentati alla Community
      • News Ufficiali da Connect.gt
      • Internet News
      • A Scuola Di
      • Digital Marketing
      • Intelligenza Artificiale
      • SEO & GEO
      • Web Marketing e Content
      • Google Analytics e Web Analytics
      • Google Ads & Advertising
      • YouTube
      • TikTok, Instagram e altri Social
      • Google Adsense, Affiliazioni e Guadagno
      • E-Commerce
      • Coding e Sistemistica
      • Help Center: consigli per il tuo progetto
      • Hosting e Cloud
      • Coding
      • CMS & Piattaforme Self-Hosted
      • Annunci e Collaborazioni
      • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
      • Collaborazioni WEB e Lavoro: offro e cerco
      • Impresa, Fisco e Leggi
      • Consulenza Legale e Professioni Web
      • Consulenza Fiscale, Imprese, Startup e P.Iva
      • Gli Off Topic
      • PC, Smartphone e altri Hardware
      • Tutti i Software
      • GT Fetish Cafè
      • Discussioni
      • Non letti 0
      • Recenti
      • Hashtag
      • Popolare
      • Utenti
      • Privacy
      • Termini e condizioni
      • © 2026 Search On Media Group S.r.l.