Click here to Skip to main content
15,893,923 members
Articles / Programming Languages / Javascript
Article

How to Drag drop in javascript across frames(Part II)

Rate me:
Please Sign up or sign in to vote.
3.05/5 (10 votes)
11 Jun 20061 min read 44.8K   548   23   1
How to do Drag and Drop object across frame

Download sourcecode

Introduction<o:p>

In article "How to Drag Drop in javascript (Part I)", we have seen how to drag and drop objects. Now consider that there is requirement to drag some object from one frame and drop it to another frame.Also clicking on particular slide (image object)we need to maximize that slide .This document explains how to achieve this using javascript.

 

How to Drag Drop in javascript (Part I) is available at

<o:p>http://www.codeproject.com/useritems/DragDrop_Part-1_.asp

Approach<o:p>

Since object which will be dragged and dropped to different frames we need to store Id of object at common place which will be accessible from both frames.Best place is to store these Ids in container of frames .<o:p>

Sample Code <o:p>

Consider that we declare two varaibles in container frame as follows.<o:p>

    <o:p>

var srcElementId; //Id of dragged object<o:p>

var destElementId; //Id of valid drop target object  <o:p>

<o:p> 

Now we can set or get these variables in child frame.Container frame can be accessed using parent object.<o:p>

<o:p> 

e.g<o:p>

function fnGetSource()<o:p>

{<o:p>

   parent.srcElementId = event.srcElement.id ;<o:p>

}   <o:p>

<o:p> 

Here we are setting dragged object id to variable declared in parent frame container.<o:p>

<o:p> <o:p> <o:p> 

Sample Application<o:p>

Consider sample application where we need to drag image from one area and drop it to another as shown in following screens 1 and 2.

Sample screenshot

 

Sample screenshot

 

Sample screenshot<o:p>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Program Manager
India India
vishal

Comments and Discussions

 
GeneralMy vote of 1 Pin
coolestCoder15-Apr-09 4:41
coolestCoder15-Apr-09 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.