Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 17987
  • Last Modified:

Firefox - mousemove events.

In a webapp, I have a page with a left and right frame. There are mousemove events in both frames.

If you look at the example below(Also available at http://www.kalleland.no/users/0115/frametest.html), you will see something strange in firefox when you do this:

1) Move the mouse pointer to the right frame
2) Press down the left mouse button
3) Hold it down while moving the mouse pointer to the left frame
4) Look at the mouse coordinates on the screen. It shows negative values. You can even move the mouse away from the browser window and the mousemove event in the right frame is still running.

This is just an example that illustrates the problem. What I'm asking for is a solution on how to activate the mousemove event in the left frame when the mouse enters it.

Thanks in advance!

Batalf

Sources:
-----------------------------------------------------------------------------------
index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> 
<html>
     <head>
     <title>Test</title>
     </head>
     <frameset cols="200,*">
          <frame src="left.html" frameborder="no" scrolling="auto">
          <frame src="right.html" frameborder="no" scrolling="auto">
     </frameset>
</html>


left.html and right.html (Same content)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
     <title>Test</title>
     <script type="text/javascript">    
     function showMessage(e){
          if(document.all)e = event;
          document.getElementById('theDiv').innerHTML = 'moving'+e.clientX;
          return false;
     }
     document.documentElement.onmousemove =  showMessage;
     </script>
</head>
<body>
<div id="theDiv">
</div>
</body>
</html>

-----------------------------------------------------------------------------------
0
Batalf
Asked:
Batalf
  • 5
  • 4
1 Solution
 
COBOLdinosaurCommented:
Alf,

You have nothing to end the event.  Normally the blur would end it but the blur is not going to occur until you focus on the other frame.  Moving the mouse does not change focus; that takes a click. I think you will have to put scripting in the frameset.  Then keep testing for a negative value in clientX to call a function in the frameset to change the focus.  I'm not sure if just stting focus that will will fire the blur so you might need to do somthing like frames['right'].blur();frames['left'].focus();

Cd&
0
 
COBOLdinosaurCommented:
Hmmm... looking at it closer, you might have to set a flag on the mouse down and clear it on the mouse up.  That way you only need to test the x value when the flag is set.

Cd&
0
 
COBOLdinosaurCommented:
Hold on I think I foudn a good solid way of doing it through proper DOM methods.  Firefox should support releaseEvents:


http://www.mozilla.org/docs/dom/domref/dom_window_ref88.html

See if you can just clear it directly when the x goes negative.

Cd&
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BatalfAuthor Commented:
Thank you cd&, I appreciate your comment.

I haven't had any success with releaseEvents() yet, but I will study it more deeply tonight.

The combination blur() and focus() is the one I'm allready using, but it make the screen flicker(the split second between blur() and focus() ) in FF when you have more than one browser window and/or the javascript console open.

I well let you know how it goes. Thanks!

Batalf
0
 
BatalfAuthor Commented:
I'm going to close this one now. Thank you for your input Cd&. I appreciate it!

Conclusions:
It seems that the combination blur(),focus() is the only one that works in Firefox.

The problem doesn't seem to be related to the events. I have now created a test without any events in the right frame(http://www.kalleland.no/users/0115/frametest2.html
). The problem is the same as in the previous example. In this one, the left frame should turn red when the mouse is moving over it. As you can see, it doesn't when the mouse button is pressed down.

It looks to me that the browsers goes into some kind of "select mode" when the mouse is down. What makes me come to that "conclusion", is that I experience the same problem in IE, but got it solved by adding onselectstart="return false" to the body tag(<body onselectstart="return false">). onselectstart is as far as I know, not supported by firefox, and I haven't found any event that could replace it either. Do you know any?

Batalf


0
 
COBOLdinosaurCommented:
Looking through the supported events, I don't see anything else that is available to kill the select, that it seems to be trying to do.  Sorry Alf. It doesn't not look like there is anything else.

Cd&
0
 
BatalfAuthor Commented:
Then blur(), focus() it is...

Thank you for all your help!

Batalf
0
 
COBOLdinosaurCommented:
Thanks for the A. :^)

Cd&
0
 
BatalfAuthor Commented:
Cd&

If you interested to know, it looked like the solution to the problem was very simple.

As so many times, the solution was CSS.

The most important part.

     html,body{
           height:100%;
           width:100%;
           padding:0px;
           margin:0px;           
     }
 
I'm not quite sure why it made the trick, but it did.

Secondly, I could also disable mozilla selection by CSS:

      body
      {
          -moz-user-focus: ignore;
          -moz-user-input: disabled;
          -moz-user-select: none;
      }

Thank you again for participating in solving this very important issue for me:-)

Batalf

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now