Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    Compatibilità script explorer/firefox

    Ciao a tutti!

    Ho trovato il seguente script che mi permette di visualizzare una finestrela contenente del testo quando passo con il mouse su di un link.

    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head><script>
    var nn = (document.layers) ? 1 : 0;
    var ie = (document.all) ? 1 : 0;
    var coord_x = 0;
    var coord_y = 0;
    var auto_close = null;
    var inizio_hint = '';
    var fine_hint = '';
    var supporto = '<table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';
    if (ie) document.write('<span id="hint_txt" style="position: absolute; top: 0; left: 0; visibility: hidden; z-index: 99"></span>');
    if (nn) document.write('<layer id="hint_txt" top="0" left="0" visibility="hide" zindex="99"></layer>');
    inizio_hint += '<table border="0" cellpadding="0" cellspacing="0">';
    inizio_hint += '<tr>';
    inizio_hint += '<td bgcolor="#E0E0E0" width="1" height="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#E0E0E0" height="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
    inizio_hint += '</tr>';
    inizio_hint += '<tr>';
    inizio_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#FFFFE6" height="3" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
    inizio_hint += '</tr>';
    inizio_hint += '<tr>';
    inizio_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#FFFFE6" width="5" nowrap>' + supporto + '</td>';
    inizio_hint += '<td bgcolor="#FFFFE6" height="13"><font face="MS Sans Serif, Verdana, Arial" size="1" color="#000000">';
    fine_hint += '</font></td><td bgcolor="#FFFFE6" width="5" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
    fine_hint += '</tr>';
    fine_hint += '<tr>';
    fine_hint += '<td bgcolor="#E0E0E0" width="1" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#FFFFE6" height="3" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#FFFFE6" width="5" height="3" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" width="1" nowrap>' + supporto + '</td>';
    fine_hint += '</tr>';
    fine_hint += '<tr>';
    fine_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" height="1" nowrap>' + supporto + '</td>';
    fine_hint += '<td bgcolor="#000000" width="1" height="1" nowrap>' + supporto + '</td>';
    fine_hint += '</tr>';
    fine_hint += '</table>';
    if (ie) document.onmousemove = get_coord;
    if (nn) document.captureEvents (Event.MOUSEMOVE); document.onmousemove = get_coord;
    function get_coord (e) {
    if (ie) {
    coord_x = event.clientX + document.body.scrollLeft;
    coord_y = event.clientY + document.body.scrollTop;
    event.srcElement.onmouseout = off_hint;
    } 
    if (nn) {
    coord_x = e.pageX + window.pageXOffset;
    coord_y = e.pageY + window.pageYOffset;
    e.target.onmouseout = off_hint;
    }
    return true;
    }
    function hint (testo) {
    if (typeof testo != 'undefined') {
    if (testo == "") testo = "";
    clearTimeout(auto_close);
    auto_close = null;
    if (ie) {
    hint_txt.innerHTML = inizio_hint + testo + fine_hint;
    hint_txt.style.pixelTop = coord_y + 15;
    hint_txt.style.pixelLeft = coord_x;
    hint_txt.style.visibility = "visible";
    } 
    if (nn) {
    document.layers.hint_txt.document.open();
    document.layers.hint_txt.document.write(inizio_hint + testo + fine_hint);
    document.layers.hint_txt.document.close();
    document.layers.hint_txt.left = coord_x;
    document.layers.hint_txt.top = coord_y + 15;
    document.layers.hint_txt.visibility = "show";
    }
    auto_close = setTimeout("off_hint()", 10000);
    }
    }
    function off_hint () {
    if (ie) hint_txt.style.visibility = "hidden";
    if (nn) document.layers.hint_txt.visibility = "hide";
    }
    </script>
    
    <body>
    
    
    Messaggio che compare</font>')">Passa con il mouse su questo link</p>
    </body>
    </html>
    Con internet explorer funziona a meraviglia, mentre con firefox non funge.
    Sapete indicarmi il perchè di questa anomalia e se ci sono eventuali soluzioni (magari anche con script equivalenti)?

    Grazie mille.

    CIAU CIAU
    Se la vita ti sorride, ti sta prendendo per il cul0

  2. #2
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Da quel che vedo quello script funziona in IE e NN (inteso NN3 e NN4).
    Comunque e` impostato in modo vecchio: ti conviene cercarne un altro.

    PS probabilmente si fa anche senza JS, sfruttando gli attributi CSS (molto piu` portabile e adatto ai browser moderni).
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  3. #3
    Ciao, sinceramente non l'ho provato co netscape. L'ho provato solo con Explorer (funge) e Firefox (non funge).
    In giro (anche su pro.html.it) ho trovato delle soluzioni che sfruttano CSS e Javascript e che sembrano essere compatibili con la maggior parte dei browser, ma con l'unica differenza che non accettano i tag di formattazione per il testo.
    Tu sparesti indicarmi qualche alternativa?

    CIAU CIAU
    Se la vita ti sorride, ti sta prendendo per il cul0

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    ma con l'unica differenza che non accettano i tag di formattazione per il testo
    Certo, la formattazione si fa con i CSS, non con tag ed attributi HTML.
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  5. #5
    Il problema è che in questo modo se volgio cambiare dimensione, colore o cose del genere ad alcune parole del testo mi viene complicato.
    Comunque a questo indirizzo:

    http://www.walterzorn.com/tooltip/tooltip_e.htm

    ho trovato una soluzione che sembra fungere con quasi tutti i browser.

    CIAU CIAU
    Se la vita ti sorride, ti sta prendendo per il cul0

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 © 2024 vBulletin Solutions, Inc. All rights reserved.