moveelement function and Positionmessage function

Source: Internet
Author: User

functionmoveelement (elementid,final_x,final_y,interval) {if(!document.getelementbyid)return false; if(!document.getelementbyid (ElementID))return false; varelem=document.getElementById (ElementID); varxpos=parseint (Elem.style.left); varypos=parseint (elem.style.top); if(xpos==final_x&&ypos==final_y) {    return true;} if(xpos<final_x) {xpos++;} if(xpos>final_x) {xpos--;} if(ypos<final_y) {ypos++;} if(ypos>final_y) {ypos--;} Elem.style.left=xpos+ "px"; Elem.style.top=ypos+ "px"; varrepeat= "Moveelement ('" +elementid+ "'," +final_x+ "," +final_y+ "," +interval+ ")"; Movement=setTimeout (Repeat,interval); } addloadevent (movemessage);

The Moveelement function is used to move a document with an ID element attribute as long as the element ID, the final x-coordinate, the final y-coordinate, and the time interval are given. You can call this function.

 function   Positionmessage () { if  (!document.getelementbyid) return      False  ;  if  (!document.getelementbyid ("message")) return  false          var  Elem=document.getelementbyid ("message"        );        Elem.style.position  = "Absolute" ;        Elem.style.left  = "50px" ;        Elem.style.top  = "100px" ;    Moveelement ( "message", 200,100,10); }addloadevent (positionmessage);  
The Positionmessage function, which sets the document position function with the ID element attribute, can be animated with the Moveelement function.

moveelement function and Positionmessage function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.