2010-05-12 11 views

Odpowiedz

1

prosty przykład przesuwać div na stronie:

<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> 

Możesz go ulepszyć do swoich potrzeb, ale można go wykorzystać jako podstawowy pomysł, jak to zrobić.

+0

Błąd Nazwa 'MovingContent' nie istnieje w bieżącym kontekście \t E: \ Hemaa \ Form \ welcome.aspx dostał ten błąd – TinTin

+0

właśnie edytowane naprawić robaki. Spróbuj ponownie. Ostatnim błędem, który naprawiłem, była zmiana 'ClientId => ClientID'. Teraz powinno działać (przetestowałem to teraz ...) – awe

+0

nic nie dostaję na mojej stronie .. po uruchomieniu strony. – TinTin

Powiązane problemy