Visualizzazione risultati 1 fino 2 di 2

Discussione: problema con Drag and Drop Script

  1. #1
    Guest

    Predefinito problema con Drag and Drop Script

    allora.. in rete ho recuperato questa roba..
    Codice HTML:
    <style type="text/css">
    
    .drag{
    position:relative;
    cursor:hand;
    z-index: 100;
    }
    
    </style>
    
    <script type="text/javascript">
    
    /***********************************************
    * Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    
    var dragobject={
    z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
    initialize:function(){
    document.onmousedown=this.drag
    document.onmouseup=function(){this.dragapproved=0}
    },
    drag:function(e){
    var evtobj=window.event? window.event : e
    this.targetobj=window.event? event.srcElement : e.target
    if (this.targetobj.className=="drag"){
    this.dragapproved=1
    if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0}
    if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0}
    this.offsetx=parseInt(this.targetobj.style.left)
    this.offsety=parseInt(this.targetobj.style.top)
    this.x=evtobj.clientX
    this.y=evtobj.clientY
    if (evtobj.preventDefault)
    evtobj.preventDefault()
    document.onmousemove=dragobject.moveit
    }
    },
    moveit:function(e){
    var evtobj=window.event? window.event : e
    if (this.dragapproved==1){
    this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
    this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
    return false
    }
    }
    }
    
    dragobject.initialize()
    
    </script>
    con questo si crea un rettagolo blù..
    Codice HTML:
    <div class="drag" style="border: 1px solid black; width: 100px; height: 100px; background-color: blue; color: white; font-size: 120%; left: 98px; top: -4px;">Draggable DIV</div>
    ma è possibile applicare il tutto ad una tabella contenente un frame?
    Codice HTML:
    <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0">
    
    <tr>
    <td><br /></td>
    <td style="width: 800px;">
    <table style="width: 100%;" border="0" cellspacing="0" cellpadding="0">
    
    <tr>
    <td>
    <table style="width: 100%; height="23";" border="0" cellspacing="0" cellpadding="0">
    
    <tr>
    <td><img src="http://i38.servimg.com/u/f38/14/18/94/73/lingue15.gif" alt="" width="8" height="23" /></td>
    <td style="width: 100%; background-image: url(http://i38.servimg.com/u/f38/14/18/94/73/lingue17.gif); text-align: center;">&nbsp;<span style="color: #ffffff; font-size: x-small;"><strong>Mini Chat:- Clicca <a href="http://www.folliacity.net/chatbox/chatbox.forum"  target="_blank">Qui</a> per aprire la chat in una nuona finestra..</strong><br /></span></td>
    <td>
    
    
    <a href="#chat" onClick="shoh('chat');" ><img src="http://i38.servimg.com/u/f38/14/18/94/73/lingue16.gif"></a>
    
    
    
    </td>
    </tr>
    
    </table>
    </td>
    </tr>
    
    </table>
    </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td style="background-image: url(http://i38.servimg.com/u/f38/14/18/94/73/10.png);">
    
    
    
    <iframe frameborder="0" width="100%" height="300" src="http://www.folliacity.net/chatbox/chatbox.forum" scrolling="no"  resizable="yes"></iframe>
    
    
    
    </td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    Grazie in anticipo.. :)

  2. #2
    L'avatar di dementialsite
    dementialsite non è connesso Super Moderatore
    Data registrazione
    19-10-2004
    Residenza
    fuori Padova
    Messaggi
    5,046

    Predefinito

    Hai provato semplicemente inserendo il codice della tabella all'interno di quello del DIV (dove sopra hai scritto "Draggable DIV", per capirci)...?

    Stammi bene...
    Le questioni tecniche hanno risposte migliori nel forum pubblico, non trovi?

    When you don't know your next step... improvise

    ALTERVISTA WANTS YOU!
    Vuoi diventare moderatore su AlterVista? Scopri come...

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •