473,569 Members | 2,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drag and drop the image!

Hi,
I made a program to drag and drop the image using mouseevent, it only works
on IE well, not on Netscape. Does anyone has the example suitable for
Netscape? Please help. Thank you very much.

yihan
Jul 20 '05 #1
2 1617
yihan hu kiteb:
Hi,
I made a program to drag and drop the image using mouseevent, it only
works on IE well, not on Netscape. Does anyone has the example
suitable for Netscape? Please help. Thank you very much.


Can you show us the code? It might only require minor tweaking to fit.
And its something I want to do for one of my own projects too. You
wouldn't want to save me loads of time would you :)
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2
"Fabian" <la****@hotmail .com> writes:
yihan hu kiteb:
I made a program to drag and drop the image using mouseevent,
Can you show us the code? It might only require minor tweaking to fit.
And its something I want to do for one of my own projects too. You
wouldn't want to save me loads of time would you :)


Very simple example (dragging, no effect on dropping):
---
<script type="text/javascript">
function dragImg(img,evt ,how) {
how = how || "relative";
img.style.posit ion = how;
var root = document.docume ntElement || document.body;
var x = img.xPos || (how == "relative" ? 0 : img.offsetLeft) ;
var y = img.yPos || (how == "relative" ? 0 : img.offsetTop);
var mx = evt.pageX || evt.clientX + root.scrollLeft ;
var my = evt.pageY || evt.clientY + root.scrollTop;
document.onmous emove = function (evt){
evt = evt || window.event;
var newmx = evt.pageX || evt.clientX + root.scrollLeft ;
var newmy = evt.pageY || evt.clientY + root.scrollTop;
x += newmx - mx;
y += newmy - my;
mx = newmx;
my = newmy;
img.style.left = x+"px";
img.style.top = y+"px";
img.style.outli ne="2px solid gray";
img.style.zInde x = "1";
return false;
}
document.onmous eup = function () {
document.onmous emove = document.onmous eup = null;
img.xPos = x;
img.yPos = y;
img.style.outli ne = img.style.zInde x = "";
return false;
}
return false;
}
</script>
---
with
---
<img src="..." onmousedown="re turn dragImg(this,ev ent)">
---
or
---
<img src="..." style="position :absolute;"
onmousedown="re turn dragImg(this,ev ent,'absolute') ">
---

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1841
by: portraitmaker | last post by:
I found some drag and drop code on the web and modified it a little b taking out some of the stuff I didn't need. This sample allows you to drag an image in a table to another positio and swaps the images. Rather than just swap the images I would like t have it insert the image and move the other images down one position (or up) What would...
6
2639
by: Colin Young | last post by:
I've got a owner-drawn listview control that displays images and now I'm trying to implement drag and drop so I can drag images from the control and drop them onto other applications. So far if I drop on windows explorer it works (i.e. an image file is created where I dropped the image) or the console displays the full path to the image....
3
3871
by: Goldwind | last post by:
Hi, I"m trying to use drag & drop of text from one text box to another but without suceess. Microsoft presented an example in "101 code samples" BUT in this example the code select and drag all the text in the TextBox, wether the user wants or not. I need to drag only the selected text (changing the example causes it not to work).
2
9700
by: TarheelsFan | last post by:
I am having problems with drag and drop into a listview. I am able to drag and drop items from within the listview, as well as drag items from the listview and drop into a picturebox. However, I am not able to drag the text or image from the picturebox to the listview. In the listview_dragenter function, I have e.Effects =...
2
2939
by: sebastian.janoschka | last post by:
Hi, I build my first Drag & Drop with JavaScript and I would like to drag the pictures when I click on it. When I create a normal div tag with some text the script works, but when I put a image in the div tag it works not correctly. Here is my Code... I integrated three pictures and one text, then you can see the differences.
6
6458
by: Alfonso2968 | last post by:
Hello, If someone can help plz. I have searched everything and all I can find is how to drag and drop within a form from panel to panel. What I need to do is Drag an image from the desktop or from an open folder to a panel on my form. This will be done for a few images and then on Buttonclik I need to save each image in its own folder.
0
1714
by: Truevision .Net | last post by:
Hi, I have a problem with drag and drop functionality when it comes to dropping pictures from sources like for example internet explorer and the webbrowser control. Dragging and dropping from picturebox to picturebox works just fine. This part of the program is basically that it navigates to a page in a webbrowser control and on this...
2
1529
by: ecashatt | last post by:
I'm a rookie trying to learn Visual Basic 2008 Express and I have created an app that includes a web browser. I need to drag and drop text and images from the browser into form controls. I currently am able to highlight text and drag it into a textbox fine. I would like to be able to drag a hyperlink into a textbox and get the links displayed text...
0
2172
by: jgraham | last post by:
I am trying to figure out how to receive images that are dropped from a web browser (IE or Firefox). For instance, after performing an image search on Google, I have several thumbnails displayed in the web browser. I would simply like to be able to drag and drop one of the thumbnails onto my application and receive the image or a URL for the...
0
7605
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...
0
7917
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. ...
0
8118
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...
1
7665
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...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
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...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.