2010-05-12 8 views

Respuesta

1

ejemplo Simple para deslizarse un div sobre la página:

<asp:Panel id="MovingContent" runat="server" 
    style="position:absolute;left:-100px;top:20px;height:40px;width:100px;"> 
The content that will move 
</asp:Panel> 

<script type="text/javascript"> 

//Initial position 
//(should be the same as the position specified in the element's style) 
posX = -100; 
posY = 20; 

//Position where the element will stop 
targetX=200; 
targetY=60; 

function move(){ 
if(posX < targetX){ 
    posX += 10; 
    if(posY < targetY) posY += 1; 
    var divElement = document.getElementById('<%=MovingContent.ClientID%>'); 
    divElement.style.left = posX + 'px'; 
    divElement.style.top = posY + 'px'; 

    //Time in milliseconds to when to move next step 
    self.setTimeout('move()', 100); 

} 
} 

move(); //Start the moving 

</script> 

Puede mejorarlo según sus necesidades, pero esto puede usarse como una idea básica de cómo hacerlo.

+0

error El nombre 'MovingContent' no existe en el actual contexto \t E: \ Hemaa \ Form \ welcome.aspx tiene este error – TinTin

+0

acabo de fijar editado los insectos. Inténtalo de nuevo. El último error que arreglé fue cambiar 'ClientId => ClientID'. Ahora debería funcionar (lo he probado ahora ...) – awe

+0

No obtengo nada en mi página ... después de ejecutar la página. – TinTin

Cuestiones relacionadas