473,395 Members | 1,688 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Passing the event to the handling function with an onmousemove event

I've created a window management object for my ajax pages. It opens windows and attaches them to the DOM element specified and then keeps track of them and removes them from DOM when the user closes them. I'm trying to add drag and drop. I am able to assign the mouse event handlers to them, but unable to send the event to the function.

Expand|Select|Wrap|Line Numbers
  1. // This is assigned to the parent of the window that has been selected to move
  2. openWindow.parents[this_win].onmousemove = openWindow.move(event);
  3. // Move functuion
  4. openWindow.move = function (evt) {
  5.    if (evt.pageX) {  // My friend Firefox
  6.        Y = evt.pageY;
  7.        X = evt.pageX;
  8.    } else if (evt.clientX) { // Worthless IE
  9.       Y=evt.clientY;
  10.        X=evt.clientX;
  11.    } else { 
  12.       return false;
  13.    }
  14.    if (Y < openWindow.lastY) {
  15.      openWindow.mover.style.top=(parseInt(openWindow.mover.style.top)-Y);
  16.    } else if (Y > openWindow.lastY) {
  17.      openWindow.mover.style.top=(parseInt(openWindow.mover.style.top)-Y);
  18.    }
  19.    .....Same for X
  20.   openWindow.lastY = Y;
  21.   openWindow.lastX =  X;
  22. }
Well anyway this won't work because the event is not being passed to the function for some reason. I assign the mousemove event handler when the user clicks and holds the mouse button on the top bar of the window. It is not assigned when the DOM element is created. is that the problem? Any help on this matter is greatly appreciated.

Thanks,
CpVermont
Feb 26 '08 #1
7 1933
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. openWindow.parents[this_win].onmousemove = function(event) { openWindow.move(event); }
Feb 28 '08 #2
Expand|Select|Wrap|Line Numbers
  1. openWindow.parents[this_win].onmousemove = function(event) { openWindow.move(event); }
Thank You very Much! It worked!!
Feb 29 '08 #3
acoder
16,027 Expert Mod 8TB
You're welcome. Glad to hear that it worked.
Mar 1 '08 #4
You're welcome. Glad to hear that it worked.
Well I believe I was a little too quick to speak. It works very well on Firefox. I use Firefox for my main (default) browser. I have an issue with Microsoft (I won't go into it here). Anyway for compatibility's sake I tried the window object with IE. And the same problem arose. In firefox the event passes to the function perfectly, but in IE the event doesn't pass at all. In a perfect world everyone would have Firefox. Anyway your insight into this would be much appreciated. I'm close to abandoning the drag and drop thing all together, but even if I do I'll soon be back to trying to solve the problem!
Mar 4 '08 #5
acoder
16,027 Expert Mod 8TB
IE uses the global window.event for event handling. Try adding that ceck in your move function, e.g. evt = evt || window.event.
Mar 4 '08 #6
Again thank you Very much. I assigned the event handlers to the DOM elements (the parent and window) like this

Expand|Select|Wrap|Line Numbers
  1. openNewWindow.parents[this_parent].onmousemove =
  2.  function (event) {
  3. if (!event) {event = window.event;}
  4. openNewWindow.moveMe(event);
  5. }
That works good if FF and IE. Thank you very much your help is very very much appreciated!
Mar 6 '08 #7
acoder
16,027 Expert Mod 8TB
Again you're welcome ;)
Mar 6 '08 #8

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

Similar topics

3
by: Need_help | last post by:
I have script that fetches the coordinates from mouse. I would like to pass this mouse coordinates to page2.asp How can I do that? <script language="JavaScript1.2"> <!-- // Detect if the...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
2
by: | last post by:
I have this code: ----------------- <script> function handler(the_event) {..............} </script> <img onmousemove="handler(????????)"> ----------------- how can I send the produced...
5
by: Ravi | last post by:
In IE (tested IE6 on W2k&WXP) onmousemove event appears to fire continually when mouse is over the document and not moving or touched at all, even when mouse is physically detached from the...
6
by: Max | last post by:
Last time I tried to explain this on another forum it didn't go too well, so I'll try my best and if you know what I'm talking about then please tell me how to do this. I have a class, inside I...
7
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been...
4
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript....
15
hsriat
by: hsriat | last post by:
<body onmousemove="moveMe()"> This function can also be called as document.onmousemove = function {moveMe();}; Similarly what can be done for onmousemove="moveMe(event)" ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...

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.