Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 30
  1. #1
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649

    [soluzione] livelli sopra campi select

    una soluzione per evitare che i campi select "buchino" i livelli,
    provare x credere il codice qui sotto (un tooltip immune dal morbo) ripreso dalla discussione originale
    codice:
    <HTML>
    <HEAD>
    <TITLE>Simple ToolTip</TITLE>
    <SCRIPT language="JavaScript">
    
    /************************************************************************************
    * Note:*******************************************************************************
    * The use of methods with oToolTip._ prefix is for internal use only (I wish there was a private/public)*
    * In order to use this code you just need to use the oToolTip.showToolTip and the oToolTip.hideToolTip*
    * methods.****************************************************************************
    *************************************************************************************/
    
    var oToolTip = new Object();
    oToolTip._topDivZIndex = 10000;
    oToolTip._oBody = null;
    oToolTip._oHelperIframe = null;
    oToolTip._oToolTipDiv = null;
    oToolTip._mousePos = new Object();
    // Add dynamic div to the page
    oToolTip._init = function(){
    // Creating and adding dynamic iframe to the page source.
    oToolTip._oBody = document.getElementsByTagName("BODY").item(0);
    oToolTip._oHelperIframe = document.createElement("IFRAME");
    oToolTip._oHelperIframe.style.border = 0;
    oToolTip._oHelperIframe.width = 0;
    oToolTip._oHelperIframe.height = 0;
    oToolTip._oHelperIframe.style.position = "absolute";
    oToolTip._oBody.appendChild(oToolTip._oHelperIframe);
    
    // Creating and adding dynamic DIV to the page source (for the tool-tip).
    oToolTip._oToolTipDiv = document.createElement("DIV");
    oToolTip._oToolTipDiv.style.border = 0;
    oToolTip._oToolTipDiv.width = 0;
    oToolTip._oToolTipDiv.height = 0;
    oToolTip._oToolTipDiv.style.position = "absolute";
    oToolTip._oBody.appendChild(oToolTip._oToolTipDiv);
    
    oToolTip._attachToEvent(document, 'onmousemove', oToolTip._mousemove);
    }
    
    // Should return the div actual width.
    oToolTip._getToolTipDivWidth = function(){
    // We are checking the inner table because of a bug in NS/Mozilla with the DIV-->offsetWidth
    var tableWidth = "" + oToolTip._oToolTipDiv.getElementsByTagName("table").item(0).offsetWidth;
    if(tableWidth.indexOf('px') > -1){
    return parseInt(tableWidth.substring(0, tableWidth.infexOf('px')));
    } else {
    return tableWidth;
    }
    }
    
    // Should return the div actual Height.
    oToolTip._getToolTipDivHeight = function(){
    // We are checking the inner table because of a bug in NS/Mozilla with the DIV-->offsetHeight
    var tableHeight = "" + oToolTip._oToolTipDiv.getElementsByTagName("table").item(0).offsetHeight;
    if(tableHeight.indexOf('px') > -1){
    return parseInt(tableHeight.substring(0, tableHeight.infexOf('px')));
    } else {
    return tableHeight;
    }
    }
    
    oToolTip._mousemove = function(e){
    if(typeof(e) == 'undefined')e = event;
    oToolTip._mousePos.Y = e.clientY;
    oToolTip._mousePos.X = e.clientX;
    if(oToolTip._oToolTipDiv.style.visibility == 'visible'){
    oToolTip._fixTipPosition();
    }
    }
    
    // Will move the div and the helper iframe to the given X and Y position
    oToolTip._fixTipPosition = function(){
    // Set the Y position
    if(oToolTip._mousePos.Y > Math.round(oToolTip._oBody.clientHeight / 2)){
    // Open to top
    oToolTip._oHelperIframe.style.top = oToolTip._mousePos.Y - oToolTip._getToolTipDivHeight() + oToolTip._oBody.scrollTop; 
    } else {
    // Open to bottom
    oToolTip._oHelperIframe.style.top = oToolTip._mousePos.Y + oToolTip._oBody.scrollTop; 
    }
    
    // Set the X position
    if(oToolTip._mousePos.X > Math.round(oToolTip._oBody.clientWidth / 2)){
    // Open to left
    oToolTip._oHelperIframe.style.left = oToolTip._mousePos.X - oToolTip._getToolTipDivWidth() + oToolTip._oBody.scrollLeft; 
    } else {
    // Open to right
    oToolTip._oHelperIframe.style.left = oToolTip._mousePos.X + 5 + oToolTip._oBody.scrollLeft; 
    }
    
    oToolTip._oToolTipDiv.style.top = oToolTip._oHelperIframe.style.top;
    oToolTip._oToolTipDiv.style.left = oToolTip._oHelperIframe.style.left;
    }
    
    oToolTip._attachToEvent = function(obj, name, func) {
    name = name.toLowerCase();
    // Add the hookup for the event.
    if(typeof(obj.addEventListener) != "undefined") {
    if(name.length > 2 && name.indexOf("on") == 0) name = name.substring(2, name.length);
    obj.addEventListener(name, func, false);
    } else if(typeof(obj.attachEvent) != "undefined"){
    obj.attachEvent(name, func);
    } else {
    if(eval("obj." + name) != null){
    // Save whatever defined in the event
    var oldOnEvents = eval("obj." + name);
    eval("obj." + name) = function(e) {
    try{
    func(e);
    eval(oldOnEvents);
    } catch(e){}
    };
    } else {
    eval("obj." + name) = func;
    }
    }
    }
    
    // Will show the div and the helper iframe.
    oToolTip.showToolTip = function(toolTipMessage){
    oToolTip._oHelperIframe.style.zIndex = oToolTip._topDivZIndex++;
    var divContent = "<table style='border:1px solid black;background-color:LightGoldenrodYellow' cellspacing='0' cellpading='0'><tr><td>" + toolTipMessage + "</td></tr></table>";
    oToolTip._oToolTipDiv.innerHTML = divContent; 
    oToolTip._mousePos
    oToolTip._oToolTipDiv.style.zIndex = oToolTip._topDivZIndex++;
    oToolTip._oHelperIframe.style.top = oToolTip._oToolTipDiv.style.top;
    oToolTip._oHelperIframe.style.left = oToolTip._oToolTipDiv.style.left;
    oToolTip._oHelperIframe.width = oToolTip._getToolTipDivWidth();
    oToolTip._oHelperIframe.height = oToolTip._getToolTipDivHeight();
    oToolTip._oHelperIframe.style.visibility = 'visible';
    oToolTip._oToolTipDiv.style.visibility = 'visible';
    
    oToolTip._fixTipPosition();
    }
    
    // Will hide the div and the helper iframe.
    oToolTip.hideToolTip = function(){
    oToolTip._oHelperIframe.style.visibility = 'hidden';
    oToolTip._oToolTipDiv.style.visibility = 'hidden';
    }
    
    // Attach to the onload event
    oToolTip._attachToEvent(window, 'onload', oToolTip._init);
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <span onMouseOver="oToolTip.showToolTip('Over the span tag')" onMouseOut="oToolTip.hideToolTip()">Move mouse over this text</span>
    
    
    Move mouse over the select box
    <SELECT onMouseOver="oToolTip.showToolTip('Selected text is: ' + this.options[this.selectedIndex].text)" onMouseOut="oToolTip.hideToolTip()">
    <OPTION>Peace</OPTION>
    <OPTION>Salam</OPTION>
    <OPTION>Shalom</OPTION>
    </SELECT>
    </body>
    </html>
    [per chi ancora non lo sapesse, è consigliabile copiare il codice che appare premendo il tastino quote in basso a destra]

  2. #2
    ottimo Buc... ehm Xinod!

    ;)

  3. #3
    Con Opera non è compatibile, vero?

  4. #4
    Ho provato con IE6, Mozzila, Opera e non funge.
    IE mi dice "Quantificatore imprevisto" . Chevvordì??

    Ranza

  5. #5
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649

    Re: [soluzione] livelli sopra campi select

    Originariamente inviato da Xinod
    [per chi ancora non lo sapesse, è consigliabile copiare il codice che appare premendo il tastino quote in basso a destra]

  6. #6
    Mamma mia che figura di m.....
    Funziona alla grande su IE6 * e Mozzilla 1.4!!
    Su Opera 7.11 no.
    Scusatemi ancora, adesso vado a controllare che cosa avevo copiato nella pagina!
    Grazie ancora

    Ranza

    * Versione completa: IE 6.0.2800.1106.xpsp2.030422-1633
    Ranza - Caro Bill ti posso dire una cosa?? Vai a cacare.

  7. #7
    Io ho copiato tutto giusto, tramite quote, ma come già detto su Opera non funziona...

  8. #8
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    ok, non funziona con opera,
    è un esempio x risolvere un problema preciso,
    mica pretende di essere il sistema di tooltip definitivo...

    edit: per un sistema di tooltip customizzabile e con una buona compatibilità vedi qui

  9. #9
    Utente di HTML.it
    Registrato dal
    Nov 2001
    Messaggi
    63
    solo qualche smussatina qua e là, per espanderlo a opera7, niente di più (ho lasciato a casa il macete)
    ciauz.


    <HTML>
    <HEAD>
    <TITLE>Simple ToolTip</TITLE>
    <SCRIPT language="JavaScript">

    var oToolTip = new Object();
    var hasIframe = (document.all && !window.opera)?1:0;
    oToolTip._topDivZIndex = 10000;
    oToolTip._oBody = null;
    oToolTip._oHelperIframe = null;
    oToolTip._oToolTipDiv = null;
    oToolTip._mousePos = new Object();


    oToolTip._init = function(){

    oToolTip._oBody = document.body;
    if(!oToolTip._oBody)
    oToolTip._oBody = document.getElementsByTagName("BODY").item(0);


    if(hasIframe){
    oToolTip._oHelperIframe = document.createElement("IFRAME");
    oToolTip._oHelperIframe.style.border = 0;
    oToolTip._oHelperIframe.width = 0;
    oToolTip._oHelperIframe.height = 0;
    oToolTip._oHelperIframe.style.position = "absolute";
    oToolTip._oBody.appendChild(oToolTip._oHelperIfram e);
    }

    oToolTip._oToolTipDiv = document.createElement("DIV");
    oToolTip._oToolTipDiv.style.border = 0;
    oToolTip._oToolTipDiv.width = 0;
    oToolTip._oToolTipDiv.height = 0;
    oToolTip._oToolTipDiv.style.position = "absolute";
    oToolTip._oBody.appendChild(oToolTip._oToolTipDiv) ;

    oToolTip._attachToEvent(document, 'onmousemove', oToolTip._mousemove);
    }


    oToolTip._getToolTipDivWidth = function(){

    var tableWidth = "" + document.getElementById("oToolTipTable").offsetWid th;
    if(tableWidth.indexOf('px') > -1){
    return parseInt(tableWidth.substring(0, tableWidth.infexOf('px')));
    } else {
    return tableWidth;
    }
    }

    oToolTip._getToolTipDivHeight = function(){
    var tableHeight = "" + document.getElementById("oToolTipTable").offsetHei ght;
    if(tableHeight.indexOf('px') > -1){
    return parseInt(tableHeight.substring(0, tableHeight.infexOf('px')));
    } else {
    return tableHeight;
    }
    }

    oToolTip._mousemove = function(e){
    if(typeof(e) == 'undefined')e = event;
    oToolTip._mousePos.Y = e.clientY;
    oToolTip._mousePos.X = e.clientX;
    if(oToolTip._oToolTipDiv.style.visibility == 'visible'){
    oToolTip._fixTipPosition();
    }
    }


    oToolTip._fixTipPosition = function(){

    var scl = (document.all||window.opera)?
    [oToolTip._oBody.scrollTop,oToolTip._oBody.scrollLe ft]:[pageYOffset,pageXOffset];
    var clt = (document.all||window.opera)?
    [oToolTip._oBody.offsetHeight,oToolTip._oBody.offse tWidth]:[innerHeight,innerWidth];

    if(oToolTip._mousePos.Y > Math.round(clt[0] / 2)){


    oToolTip._oToolTipDiv.style.top = oToolTip._mousePos.Y - oToolTip._getToolTipDivHeight() + scl[0];
    } else {

    oToolTip._oToolTipDiv.style.top = oToolTip._mousePos.Y + scl[0];
    }


    if(oToolTip._mousePos.X > Math.round(clt[1] / 2)){
    oToolTip._oToolTipDiv.style.left = oToolTip._mousePos.X - oToolTip._getToolTipDivWidth() + scl[1];
    } else {

    oToolTip._oToolTipDiv.style.left = oToolTip._mousePos.X + 5 + scl[1];
    }
    if(hasIframe){
    oToolTip._oHelperIframe.style.top = oToolTip._oToolTipDiv.style.top;
    oToolTip._oHelperIframe.style.left = oToolTip._oToolTipDiv.style.left;}
    }

    oToolTip._attachToEvent = function(obj, name, func) {
    name = name.toLowerCase();

    if(obj.addEventListener) {
    if(name.length > 2 && name.indexOf("on") == 0) name = name.substring(2, name.length);
    obj.addEventListener(name, func, false);
    } else if(typeof(obj.attachEvent) != "undefined"){
    obj.attachEvent(name, func);
    } else {
    if(obj[name] != null){

    var oldOnEvents = obj[name];
    obj[name] = function(e) {
    try{
    func(e);
    eval(oldOnEvents);
    } catch(e){}
    };
    } else {
    obj[name] = func;
    }
    }
    }


    oToolTip.showToolTip = function(toolTipMessage){
    if(hasIframe)oToolTip._oHelperIframe.style.zIndex = oToolTip._topDivZIndex++;
    var divContent = "<table id='oToolTipTable' style='border:1px solid black;background-color:"
    + "LightGoldenrodYellow' cellspacing='0' cellpading='0'><tr><td>"
    + toolTipMessage + "</td></tr></table>";
    oToolTip._oToolTipDiv.innerHTML = divContent;
    oToolTip._mousePos
    oToolTip._oToolTipDiv.style.zIndex = oToolTip._topDivZIndex++;
    if(hasIframe){
    oToolTip._oHelperIframe.style.top = oToolTip._oToolTipDiv.style.top;
    oToolTip._oHelperIframe.style.left = oToolTip._oToolTipDiv.style.left;
    oToolTip._oHelperIframe.width = oToolTip._getToolTipDivWidth();
    oToolTip._oHelperIframe.height = oToolTip._getToolTipDivHeight();
    oToolTip._oHelperIframe.style.visibility = 'visible';
    }
    oToolTip._fixTipPosition();
    oToolTip._oToolTipDiv.style.visibility = 'visible';
    }


    oToolTip.hideToolTip = function(){
    if(hasIframe){
    oToolTip._oHelperIframe.style.visibility = 'hidden';}
    oToolTip._oToolTipDiv.style.visibility = 'hidden';
    }


    oToolTip._attachToEvent((window.opera)?document:wi ndow, 'onload', oToolTip._init);


    </SCRIPT>
    </HEAD>
    <BODY>
    <span
    onMouseOver="oToolTip.showToolTip('Over the span tag')"
    onMouseOut="oToolTip.hideToolTip()">Move mouse over this text</span>


    Move mouse over the select box
    <SELECT
    onMouseOver="oToolTip.showToolTip('Selected text is: '
    + this.options[this.selectedIndex].text)"
    onMouseOut="oToolTip.hideToolTip()" onclick="oToolTip.hideToolTip()">
    <OPTION>Peace</OPTION>
    <OPTION>Salam</OPTION>
    <OPTION>Shalom</OPTION>
    </SELECT>
    </body>
    </html>
    javascript: tutto attaccato

  10. #10
    e per i classici menù a tendina esiste qualche cosa??? anche loro hanno questo problema!!

    Intendo dire i menù con i div e/o livelli (credo si chiamino così...

    se trovo il link ve lo posto!!
    www.skorpiograph.com - [ PORTFOLIO ]
    ...se vuoi essere aiutato devi aiutare chi ti aiuta ad aiutarti!!!

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.