Using Yui to create their own drag-and-drop web page

Source: Internet
Author: User
Tags blog layout

The first time you can see in the Web page like the client software drag and drop is on the 3721 site, at that time did not see the day to understand. Now this technology has a lot of applications, which we feel the deepest is the Sohu,sina blog layout function, compared to ordinary other pages, I believe we can feel the existence of its advantages.

A lot of people ask, what kind of technology does this web page do? Good to learn. It is actually implemented in JavaScript and is a high-level application of JavaScript. To write all of their own code of work will be relatively large, we can use the mature Yui (Yahoo user Interface Library) to do. Yui everyone can go to Yahoo's website download. The website is: http://developer.yahoo.com/yui/.

Here is an analysis that I do with examples:

<script type= "Text/javascript" src= ". /.. /build/yahoo/yahoo-min.js "></script>
<script type= "Text/javascript" src= ". /.. /build/event/event-min.js "></script>
<script type= "Text/javascript" src= ". /.. /build/dom/dom-min.js "></script>
<script type= "Text/javascript" src= ". /.. /build/logger/logger-min.js "></script>

<script type= "Text/javascript" src= ". /.. /build/dragdrop/dragdrop-debug.js "></script>

The above 5 statements are included Yui script, all the script as long as contains these several statements can implement drag-and-drop function, the path is a relative path, you can write the script and the Yui function library location to modify.

<script type= "Text/javascript" >
newhappyapp= function () {
var dd, DD2;
return {
Init:function () {
dd = new YAHOO.util.DD ("blog");
DD2 = new YAHOO.util.DD ("Archives");

}
}
}();

YAHOO.util.Event.onDOMReady (Newhappyapp.init);
</script>

The above script is the most important script, defining a Primary object Newhappyapp, and then defining two variables in the function based on the number of layers needed to operate, initializing the two variables in the INIT function, Call the initial function for YAHOO.util.DD, is Yui provides a drag-and-drop object, parameters for the layer ID, here we use blog and archives.

<div id= "blog" > Log </div>
<div id= "Archives" > Personal files </div>

Above is defined two layers, IDs are blog and archives, respectively, representing logs and personal files.

  Put this code into a text file, save it in a Web page format, and you can see the effect of your own drag and drop. Of course, this is just a simple example, in the actual application, we can use CSS style, background, etc. to beautify it.  

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.