OnMouseOver & OnMouseOut

  • Thread starter Thread starter Mick
  • Start date Start date
M

Mick

Sorry, I need a little help please, can anyone please tell m where my code is
wrong. The new window opens on mouse over, but attempts to close the main
window on mouse out rather than the small window.

<a
onmouseover="window.open('2.asp','mywindow5','width=700,height=220,toolbar=no,resizable=no,status=no,location=no,top=200,left=400')"
onmouseout="window.close('2.asp','mywindow5')">

many thanks
mick
 
I don't believe there's anything wrong with your code, I have it working to
a certain extent - not sure if it is exactly what you're after

Take a look at my example: www.murraywebs.com/1.html

Move the mouse over the link to open "2.html"

In 2.html it opens in a new popup window defined by your dimensions
etc.....now move the mouse over the link inside that window and move the
mouse off - presto! the window closes. But if this "on mouse ouot link is
on the main page, it won't close the popup; it has to be within the page you
want to close to make that function close that window. Unless there's some
other parameter (target?) that can close another window other than the
current one, the method in my example is I think what you're wanting to do.


So:

Step 1, put this code into the main ASP page:
<a href="#"
onmouseover="window.open('2.html','mywindow5','width=700,height=220,toolbar=no,resizable=no,status=no,location=no,top=200,left=400')"
onmouseout="window.close('2.html','mywindow5')">Open this Window</a>

Step 2:
Put this code into the window that will open as the popup:
<a href="#" onmouseout="window.close('2.html','mywindow5')">Mover the mouse
over and then move it off this link to close this window</a>


If you follow the above I think it will do what you want - at least - from
my thinking, it is what you're after.

If not post back with a demonstration of what it is doing (trying to close
the main window(?)>


Note though; if the user doesn't have javascript enabled, this won't work.

Not sure why you want to use the mouseover and on mouseout functions;
wouldn't the onclick(); function be?
 
Andrew has the solution - window.close() will only close the window the
mouse is in.
However, be aware that even if JavaScript is not disabled, the pop-up may
not open - onmouseover pop-ups tend to be blocked by pop-up blockers and
modern browsers. onclick, on the other hand, will normally not be blocked.

--
Ron Symonds
Microsoft MVP (Expression Web)
http://www.rxs-enterprises.org/fp

Reply only to group - emails will be deleted unread.
 
Thank you very much Andrew for your time and suggestion, I think on what you
and Ron have suggested, I may well modifyte code to OnClick.
thanks again
Mick
 
Back
Top