Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it L'avatar di t_bee
    Registrato dal
    Feb 2002
    Messaggi
    125

    JS - funzione centra pop up e scrollbar

    Ciao a tutti,
    ho un problema che non riesco a risolvere con una pop up. Il fatto è che appare centrata, ma senza scrollbars...come faccio ad attivarli?
    Devo modificare la funzione nell'head?

    Nell'HEAD c'è la funzione per centrare la pop up:
    <script language="javascript">
    function centra(url, name, width, height) {
    if (document.all) {
    var x = window.screenLeft;
    var y = window.screenTop;
    var w = window.document.body.offsetWidth;
    var h = window.document.body.offsetHeight;
    }
    else {
    var x = window.screenX;
    var y = window.screenY;
    var w = window.outerWidth;
    var h = window.outerHeight;
    }
    var cntx = x + Math.round((w - width) / 2);
    var cnty = y + Math.round((h - height) / 2);
    window.open (url, name, 'left=' + cntx + ',top=' + cnty + ',width=' +
    width + ',height=' + height);
    }
    </script>
    E nel BODY c'è:
    Chi può aiutarmi???

  2. #2
    Utente di HTML.it
    Registrato dal
    Dec 2001
    Messaggi
    3,259
    se nn ricordo male,
    prova a cambiare questo

    window.open (url, name, 'left=' + cntx + ',top=' + cnty + ',width=' +
    width + ',height=' + height);


    con questo


    window.open (url, name, 'left=' + cntx + ',top=' + cnty + ',width=' +
    width + ',height=' + height + ',scrollbars=yes');

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    scrollbars=yes,

    Comunque il tuo script funziona solo in IE e NN4, non funziona negli altri browser. Sostituisci l'if della funzine con questo:
    codice:
    function centra(url, name, width, height) {
      if (document.all) {
        var x = window.screenLeft;
        var y = window.screenTop;
        var w = window.document.body.offsetWidth;
        var h = window.document.body.offsetHeight;
      } else if (document.layers) {
        var x = window.screenX;
        var y = window.screenY;
        var w = window.outerWidth;
        var h = window.outerHeight;
      } else {
        var x = 0;
        var y = 0;
        var w = screen.availWidth;
        var h = screen.availHeight;
      }
      var cntx = x + Math.round((w - width) / 2);
      var cnty = y + Math.round((h - height) / 2);
      window.open (url, name, 'left=' + cntx + ',top=' + cnty + ',width=' +
    width + ',height=' + height + ',scrollbars=yes');
    }
    e togli scrollbars dalla chiamata (nella chiamata gli ultimi due parametri devono essere numerici.

    Ciao
    Michele
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

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.