Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente bannato
    Registrato dal
    Feb 2004
    Messaggi
    2,803

    aggiungere ritardo al tooltip

    uso il seguente script per dei tooltip..
    tutto funge a meraviglia..ma si potrebbe aggiungere un ritardo al tooltip?
    praticamente appare appena passo sull'elemento..il che è abbastanza fastidioso

    Codice PHP:
    /*
     +-------------------------------------------------------------------+
     |                   J S - T O O L T I P   (v1.2)                    |
     |                                                                   |
     | Copyright Gerd Tentler               [email]info@gerd-tentler.de[/email]         |
     | Created: Feb. 15, 2005               Last modified: Mar. 1, 2005  |
     +-------------------------------------------------------------------+
     | This program may be used and hosted free of charge by anyone for  |
     | personal purpose as long as this copyright notice remains intact. |
     |                                                                   |
     | Obtain permission before selling the code for this program or     |
     | hosting this software on a commercial website or redistributing   |
     | this software over the Internet or in any other medium. In all    |
     | cases copyright must remain intact.                               |
     +-------------------------------------------------------------------+

    ======================================================================================================

     This script was tested with the following systems and browsers:

     - Windows XP: IE 6, NN 4, NN 7, Opera 7
     - Mac OS X:   IE 5, Safari 1

     If you use another browser or system, this script may not work for you - sorry.

    ------------------------------------------------------------------------------------------------------

     USAGE:

     Use the toolTip-function with mouse-over and mouse-out events (see example below).

     - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent)
       Note: width and opacity are optional

     - To hide a tooltip, use this syntax: toolTip()

    ------------------------------------------------------------------------------------------------------

     EXAMPLE:

     [url="#"]some text here[/url]

    ======================================================================================================
    */
      
    function TOOLTIP() {
    //----------------------------------------------------------------------------------------------------
    // Configuration
    //----------------------------------------------------------------------------------------------------
        
    this.width 200;                     // width (pixels)
        
    this.bgColor '#FFFFC0';             // background color
        
    this.textColor '#000';           // text color
        
    this.borderColor '#D00000';         // border color
        
    this.opacity 80;                    // opacity (percent) - doesn't work with all browsers
        
    this.cursorDistance 5;              // distance from cursor (pixels)

        // don't change
        
    this.text '';
        
    this.obj 0;
        
    this.sobj 0;
        
    this.active false;

    // -------------------------------------------------------------------------------------------------------
    // Functions
    // -------------------------------------------------------------------------------------------------------
        
    this.create = function() {
          if(!
    this.sobjthis.init();

          var 
    '<table border=0 cellspacing=0 cellpadding=4 width=' this.width ' bgcolor=' this.bgColor '><tr>' +
                  
    '<td align=center><font color=' this.textColor '>' this.text '</font></td></tr></table>';

          if(
    document.layers) {
            
    '<table border=0 cellspacing=0 cellpadding=1><tr><td bgcolor=' this.borderColor '>' '</td></tr></table>';
            
    this.sobj.document.write(t);
            
    this.sobj.document.close();
          }
          else {
            
    this.sobj.border '1px solid ' this.borderColor;
            
    this.setOpacity();
            if(
    document.getElementByIddocument.getElementById('ToolTip').innerHTML t;
            else 
    document.all.ToolTip.innerHTML t;
          }
          
    this.show();
        }

        
    this.init = function() {
          if(
    document.getElementById) {
            
    this.obj document.getElementById('ToolTip');
            
    this.sobj this.obj.style;
          }
          else if(
    document.all) {
            
    this.obj document.all.ToolTip;
            
    this.sobj this.obj.style;
          }
          else if(
    document.layers) {
            
    this.obj document.ToolTip;
            
    this.sobj this.obj;
          }
        }

        
    this.show = function() {
          var 
    ext = (document.layers '' 'px');
          var 
    left mouseX;

          if(
    left this.width this.cursorDistance winXleft -= this.width this.cursorDistance;
          else 
    left += this.cursorDistance;

          
    this.sobj.left left ext;
          
    this.sobj.top mouseY this.cursorDistance ext;

          if(!
    this.active) {
            
    this.sobj.visibility 'visible';
            
    this.active true;
          }
        }

        
    this.hide = function() {
          if(
    this.sobjthis.sobj.visibility 'hidden';
          
    this.active false;
        }

        
    this.setOpacity = function() {
          
    this.sobj.filter 'alpha(opacity=' this.opacity ')';
          
    this.sobj.mozOpacity '.1';
          if(
    this.obj.filtersthis.obj.filters.alpha.opacity this.opacity;
          if(!
    document.all && this.sobj.setPropertythis.sobj.setProperty('-moz-opacity'this.opacity 100'');
        }
      }

    //----------------------------------------------------------------------------------------------------
    // Build layer, get mouse coordinates and window width, create tooltip-object
    //----------------------------------------------------------------------------------------------------
      
    var tooltip mouseX mouseY winX 0;

      if(
    document.layers) {
        
    document.write('<layer id="ToolTip"></layer>');
        
    document.captureEvents(Event.MOUSEMOVE);
      }
      else 
    document.write('<div id="ToolTip" style="position:absolute; z-index:99"></div>');
      
    document.onmousemove getMouseXY;

      function 
    getMouseXY(e) {
        if(
    document.all) {
          
    mouseX event.clientX document.body.scrollLeft;
          
    mouseY event.clientY document.body.scrollTop;
        }
        else {
          
    mouseX e.pageX;
          
    mouseY e.pageY;
        }
        if(
    mouseX 0mouseX 0;
        if(
    mouseY 0mouseY 0;

        if(
    document.body && document.body.offsetWidthwinX document.body.offsetWidth 25;
        else if(
    window.innerWidthwinX window.innerWidth 25;
        else 
    winX screen.width 25;

        if(
    tooltip && tooltip.activetooltip.show();
      }

      function 
    toolTip(textwidthopacity) {
        if(
    text) {
          
    tooltip = new TOOLTIP();
          
    tooltip.text text;
          if(
    widthtooltip.width width;
          if(
    opacitytooltip.opacity opacity;
          
    tooltip.create();
        }
        else if(
    tooltiptooltip.hide();
      } 

  2. #2
    ciao, prova così:

    codice:
    onMouseOver="window.setTimeout(toolTip('Just a test', 150), 1000);"
    così il tooltip dovrebbe comparire dopo un secondo (1000 millisecondi).

    saluti

  3. #3
    Utente bannato
    Registrato dal
    Feb 2004
    Messaggi
    2,803
    ..non sembra fungere

  4. #4
    Originariamente inviato da ant_alt
    ..non sembra fungere
    sì infatti c'è un errore di sintassi, prova così:

    codice:
    onMouseOver="window.setTimeout(\"toolTip('Just a test', 150)\", 1000);"
    saluti

    P.S.: fai il quote del mio messaggio per leggere correttamente il codice

  5. #5
    Utente bannato
    Registrato dal
    Feb 2004
    Messaggi
    2,803
    Originariamente inviato da moaiamorfo
    ..
    ho quotato..
    neanche così
    ps: quelle slash sono giuste?

  6. #6
    Originariamente inviato da ant_alt
    ho quotato..
    neanche così
    ps: quelle slash sono giuste?
    così funziona, provato:

    codice:
    some text here
    sì, i backslash sono necessari (quota anche questo).

    saluti

  7. #7
    Utente bannato
    Registrato dal
    Feb 2004
    Messaggi
    2,803
    Originariamente inviato da moaiamorfo
    così funziona, provato:

    codice:
    some text here
    sì, i backslash sono necessari (quota anche questo).

    saluti
    ok ora funziona..(ma i backslash li hai messi diversamente)

    grazie

  8. #8
    Originariamente inviato da ant_alt
    ok ora funziona..(ma i backslash li hai messi diversamente)

    grazie
    sì, li ho messo in relazione a dove ho posizionato gli apici singoli.

    saluti

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.