473,805 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cross browser drag & drop

1 New Member
Hi mates,
Im developing an purely client side drag & drop application with JavaScript.
I got a code for IE 4.0 and Netscape 4.0...
while trying to update code to work in modern browsers like IE 6+,Netscape 7,Mozilla Firefox etc...,im facing some problem in line i pointed out in code below :

[HTML]<html>
<head>
<SCRIPT LANGUAGE="JavaS cript">

N = (document.all) ? 0 : 1;
var ob;
var X;
var Y;
function MD(e) {
if (N) {
ob = e.target.parent Node.style;
//alert(ob);
X=e.layerX;
Y=e.layerY;

return false;
}
else {

ob = event.srcElemen t.parentElement .style;
X=event.offsetX ;
Y=event.offsetY ;
}
}

function MM(e) {
if (ob) {
if (N) {
ob.moveTo((e.pa geX-X), (e.pageY-Y)); //The Problem line }
else {
ob.pixelLeft = event.clientX-X + document.body.s crollLeft;
ob.pixelTop = event.clientY-Y + document.body.s crollTop;
return false;
}
}
}
function MU() {
ob = null;
}

if (N) {
document.captur eEvents(Event.M OUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmous edown = MD;
document.onmous emove = MM;
document.onmous eup = MU;

</script>
</head>
<body>
<div id="s" style="position :absolute;left: 50;top:300;">
<img src=Images/spades.gif name="s" >
</div>

<div id="d" style="position :absolute;left: 50;top:350;">
<img src=Images/diamonds.gif name="d" >
</div>

<div id="c" style="position :absolute;left: 100;top:300;">
<img src=Images/clubs.gif name="c" >
</div>

<div id="h" style="position :absolute;left: 100;top:350;">
<img src=Images/hearts.gif name="h" >
</div>

<div id="riyaz" style="position :absolute;left 400;top:400;">
<input type="text" name="riyaz" id = "1" value="Hello"></input>
</div>

Just click and hold the 4 suit images to the left and then you can move them around the page!

<p><center>
<font face="arial, helvetica" size="-2">Getting Bored Click Here !<br>
by <a href="http://jokes.yahoo.com ">Riyaz</a></font>
</center><p>

</body>
</html>
[/HTML]
Im a new developer and quite frustrated with this browser incompatilbilit ies..Please help me out.
Regards
Riyaz
Mar 1 '06 #1
1 4931
acoder
16,027 Recognized Expert Moderator MVP
There are quite a lot of incompatibiliti es in getting the correct mouse position cross-browser. This link will help.

As for cross-browser drag-drop, get a modern script using a simple search for "javascript drag drop".
Apr 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2754
by: olimoli | last post by:
Hi, I'm looking for a javascript that lets me drag an image from one browser window to another. Is there a solution for this problem? Cheers Olaf
1
7648
by: Karsten Schramm | last post by:
Hi, if I drag an Outlook.MailItem to a Windows-Explorer window a <subject>.msg file will be created. Now I try to drag & drop a mail item to my own WinForm app. Unfortunately it doesn't work. In the "drop event" are eight DataFormats (e.Data.GetFormats()) but the important one (imho) "FileContents" is "Nothing"/"null".
0
2283
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly delicately balanced and finding my way through it has descended into one of those awful situations which I refer to as guess & test. From the point at which DoDragDrop() function is called until some later
0
1491
by: David Winter | last post by:
I have a particular application that requires reordering objects by drag and drop, and I would like to do this with a web frontend. To be more precise: There are headlines and paragraphs stored in a database, but forcing the editors to put them into a certain sequence by entering a sequence number for every item (or clicking on an "up" button fifty times) would be much too cumbersome. So I want to give them an outline view of the text...
5
2890
by: chris | last post by:
I have a bit of JavaScript code (see below) that handles drag-and-drop of elements on a webpage, simply moving them around the page. The problem I'm having occurs when the user drags the object outside the browser window and releases. The JavaScript onmouseup event fails to fire (as is consistent with the language spec), and the element is left in a "dragging limbo" - it follows the mouse cursor once it returns inside the window (despite...
2
9211
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application users. Moreover, when the user double click on the component, they can define some routing rules for the process. Is it possible to have such fancy UI in C#?? Any reference sites or tutorial?? Million Thanks.
1
2316
by: Terry Olsen | last post by:
My first time using TreeViews. I have TreeView1 set up to display my directory structure just like Windows Explorer. I can drag & drop files and folders over to TreeView2. I can re-arrange the structure in TreeView2 (putting files in different folders and such...like you do when you create a structure for burning a CD). I have two questions. 1. How can I remember the full path from TreeView1 (when it comes time to actually do...
3
10602
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
5
13817
by: Romulo NF | last post by:
Greetings, I´m back here to show the new version of the drag & drop table columns (original script ). I´ve found some issues with the old script, specially when trying to use 2 tables with drag&drop on the same page (which was not possible). Now i´ve a new concept of the script, more object oriented. I´ve also commented the whole code so you guys can easier understand it engine. What exactly we need when trying to make a column drag &...
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.