JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2057
Number of posts: 5155

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
determining mouse position Posted by mac_doggie on 16 Oct 2002 at 1:40 AM
I want to create a popup window on the position of the mouse. I want to use this for a popup menu. Something like:

<img onMouseOver="Popup(this)">

<script Language="JavaScript">
<!--
  function Popup(obj) {
    win = window.open('','','left:'+obj.left+';top:'+obj.top+';dependent;');
  }
//-->
</script>


Do You get what I mean ?
(ofcourse the code above does not work!)
I'd also like to get rid of the titlebar of the popup window, so that the users won't see it as the popupwindow but as a popupmenu...

can anyone help me with that ?



-mac-
mailto:programmersheaven@mac-doggie.nl
the Netherlands...

Report
Re: determining mouse position Posted by bgibby on 16 Oct 2002 at 10:02 PM
: I want to create a popup window on the position of the mouse. I want to use this for a popup menu. Something like:
:
:
: <img onMouseOver="Popup(this)">
: 
: <script Language="JavaScript">
: <!--
:   function Popup(obj) {
:     win = window.open('','','left:'+obj.left+';top:'+obj.top+';dependent;');
:   }
: //-->
: </script>
: 

:
: Do You get what I mean ?
: (ofcourse the code above does not work!)
: I'd also like to get rid of the titlebar of the popup window, so that the users won't see it as the popupwindow but as a popupmenu...
:
: can anyone help me with that ?
:
:
:
: -mac-
: mailto:programmersheaven@mac-doggie.nl
: the Netherlands...
:
:

Hi there,

Yep I understand what you're trying to do.

There's no way to actually remove the pop-up's Title bar. The only time the title bar is not present is during full screen mode in IE. NS still retains the title bar.

So your only other way to do it is to use <DIV>'s.

It also depends upon which browser you're trying to develop for.

window.event.x and window.event.y give you the precise mouse coordinates. In your popup code, you can use these two to get where the mouse is when the function is fired.

HTH
Bradley q:)
Report
Re: determining mouse position Posted by mac_doggie on 17 Oct 2002 at 12:40 AM
: : I want to create a popup window on the position of the mouse. I want to use this for a popup menu. Something like:
: :
: :
: : <img onMouseOver="Popup(this)">
: : 
: : <script Language="JavaScript">
: : <!--
: :   function Popup(obj) {
: :     win = window.open('','','left:'+obj.left+';top:'+obj.top+';dependent;');
: :   }
: : //-->
: : </script>
: : 

: :
: : Do You get what I mean ?
: : (ofcourse the code above does not work!)
: : I'd also like to get rid of the titlebar of the popup window, so that the users won't see it as the popupwindow but as a popupmenu...
: :
: : can anyone help me with that ?
: :
: :
: :
: : -mac-
: : mailto:programmersheaven@mac-doggie.nl
: : the Netherlands...
: :
: :
:
: Hi there,
:
: Yep I understand what you're trying to do.
:
: There's no way to actually remove the pop-up's Title bar. The only time the title bar is not present is during full screen mode in IE. NS still retains the title bar.
:
: So your only other way to do it is to use <DIV>'s.
:
: It also depends upon which browser you're trying to develop for.
:
: window.event.x and window.event.y give you the precise mouse coordinates. In your popup code, you can use these two to get where the mouse is when the function is fired.
:
: HTH
: Bradley q:)
:
Thanks for your reply. I thought that I did see explorerwindows without titelbar, but I guess I'm wrong then. I thought of <DIV>'s too, but if I am using frames De popup menu won't appear over the other frame, it just creates a scrollbar in it's own frame (know what I mean?) If anyone can figure out a way to get rid of the titelbar please let me know... (I could allways create my own browser in VB hihi)



-mac-
mailto:programmersheaven@mac-doggie.nl
the Netherlands...


Report
Re: determining mouse position Posted by borislav on 24 Oct 2002 at 3:45 AM
: I want to create a popup window on the position of the mouse. I want to use this for a popup menu. Something like:
:
:
: <img onMouseOver="Popup(this)">
: 
: <script Language="JavaScript">
: <!--
:   function Popup(obj) {
:     win = window.open('','','left:'+obj.left+';top:'+obj.top+';dependent;');
:   }
: //-->
: </script>
: 

:
: Do You get what I mean ?
: (ofcourse the code above does not work!)
: I'd also like to get rid of the titlebar of the popup window, so that the users won't see it as the popupwindow but as a popupmenu...
:
: can anyone help me with that ?
:
:
:
: -mac-
: mailto:programmersheaven@mac-doggie.nl
: the Netherlands...
:
:

Hey there is a better way to do this:

<img name="dsasdads" onMouseDown="your_func(this.name)">

<script>
function your_func(name){
//name is the image name
// mouse coordinates are
var mx=event.clientX;
var my=event.clientY;
window.open("whereyougo.htm?mouseX="+mx+"&MouseY="+my,"","locationbar=no,toolbar=no,status=no");
}
</script>

in the function mx,my are mouse coordinates; name are the image name;
if you want to catch on mouse move event simply change onMouseDown=... with onMouseMove.
Note: this will work only IE.
Report
Re: determining mouse position Posted by bgibby on 24 Oct 2002 at 4:54 PM
: Hey there is a better way to do this:
:
: <img name="dsasdads" onMouseDown="your_func(this.name)">
:
: <script>
: function your_func(name){
: //name is the image name
: // mouse coordinates are
: var mx=event.clientX;
: var my=event.clientY;
: window.open("whereyougo.htm?mouseX="+mx+"&MouseY="+my,"","locationbar=no,toolbar=no,status=no");
: }
: </script>
:
: in the function mx,my are mouse coordinates; name are the image name;
: if you want to catch on mouse move event simply change onMouseDown=... with onMouseMove.
: Note: this will work only IE.
:

window.event.x and window.event.y works in both IE4+ & NS4+

Cya
Bradley q:)
Report
Re: determining mouse position Posted by borislav on 24 Oct 2002 at 10:47 PM
: : Hey there is a better way to do this:
: :
: : <img name="dsasdads" onMouseDown="your_func(this.name)">
: :
: : <script>
: : function your_func(name){
: : //name is the image name
: : // mouse coordinates are
: : var mx=event.clientX;
: : var my=event.clientY;
: : window.open("whereyougo.htm?mouseX="+mx+"&MouseY="+my,"","locationbar=no,toolbar=no,status=no");
: : }
: : </script>
: :
: : in the function mx,my are mouse coordinates; name are the image name;
: : if you want to catch on mouse move event simply change onMouseDown=... with onMouseMove.
: : Note: this will work only IE.
: :
:
: window.event.x and window.event.y works in both IE4+ & NS4+
:
: Cya
: Bradley q:)
:

Hi Cya,
You are completely right, but problem is to determine the exact mouse position in the object. Calculation that you must make on this way is more than you only determine browser and then you take the mouse position.

Regards
Borislav




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.