473,472 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
Create 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="JavaScript">

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

return false;
}
else {

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

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

if (N) {
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = MD;
document.onmousemove = MM;
document.onmouseup = 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 incompatilbilities..Please help me out.
Regards
Riyaz
Mar 1 '06 #1
1 4910
acoder
16,027 Recognized Expert Moderator MVP
There are quite a lot of incompatibilities 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
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
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....
0
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...
0
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...
5
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...
2
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...
1
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...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
5
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
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.