Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with and Object Event 2

Status
Not open for further replies.

bjd4jc

Programmer
Nov 8, 2001
1,627
US
I have added a web cam object to a web page. I have used this same object inside of a VB program. In VB I can program the object to have an OnClick event that sends where the Mouse X and Y position is over the image. I can't figure out how to do this in HTML/ASP. I don't necessarily need to get the coordinates from the Event itself but it is neccesary to get the coordinates somehow.

Please help!

Thanks

Brian
 
Did you try this way ?
Code:
<SCRIPT Language=&quot;JavaScript&quot; FOR=&quot;myObject&quot; EVENT=&quot;Click&quot;>
  // insert here the code for Click event on object &quot;myObject&quot;
</SCRIPT>
Water is not bad as long as it stays out human body ;-)
 
Yeah, thanks for the post. I already have this much. Now, what I need is a way to get the mouse X and Y positions from inside that event.

Thanks

Brian
 
did you try to use
Code:
clientX
and
Code:
clientY
properties of
Code:
event
object inside that kind of script ? Water is not bad as long as it stays out human body ;-)
 
Yes, I have done that and I get the error: Object Required.

Here is what I have:
Code:
var mY = 0;
var mX = 0;
  
mX = event.clientX; //   <== Error Happens Here	    
mY = event.clientY; //document.event.clientY; 
alert(&quot;X = &quot; + mX + &quot;: Y = &quot; + mY);
 
Let's take the problem another way : If the script is called, that means that your WebCam object fires a click event. Do you have the interface of this object ? may be the mouse coordonates are in ?
Let me be clearer : I had once the same problem with an OCX I wrote that I wanted to put in an HTML page. I first couldn't get mouse pos on click event in my HTML page. To solve the problem, I had to catch the mouseDown event in the OCX and then store the values of mouse pos into public properties of my OCX in order to read them in HTML. Water is not bad as long as it stays out human body ;-)
 
No, I have searched the documentation of this OCX up and down and can not find the coords anywhere. Unfortunately I can't modify this control to show that :(

 
Try to type this :
Code:
var obj = document.getElementById(&quot;myObject&quot;)
for(hh in obj) {
    document.write(hh + &quot;<br>&quot;);
}
where
Code:
myObject
is the value of id attribute of your object. This code should give you all attributes, events and properties of your object. This could help to get the interface. Water is not bad as long as it stays out human body ;-)
 
bjd4jc (your name sounds like a printer name),

HH is actually a variable declared on the fly.

You could also name it property like I do in my scripts (yet it also shows functions as well).

var obj = document.getElementById(&quot;myObject&quot;)
for(property in obj) {
document.write(property + &quot;<br>&quot;);
} Gary Haran
 
Arghh Gary, You caught me giving your code to another one. Will you ever forgive me ??? LOL LOL LOL Water is not bad as long as it stays out human body ;-)
 
Ok, I appreciate all of you helpful posts! I'll give stars here.

What I did was create two variables (mX and mY) in the head of the document. Then I do this:

Code:
<SCRIPT LANGUAGE=&quot;JavaScript&quot; FOR=&quot;document&quot; EVENT=&quot;onmousemove&quot;>    
	mX = event.clientX;
	mY = event.clientY;
</SCRIPT>

and then in my object OnClick I can reference mX and mY. This doesn't give the coordinate of the exact position from the object it gives the position from the window but that's ok because I can calculate the position in the object from that.

Again, I appreciate all your posts!

Brian
 
OK, now I am stuck again.... I only know how to get the Left and Top properties from the style and to do that you have to set the position to absolute and I don't want to do that. Is there another way to get the where the ActiveX control is from the top of the document and from the left of the document?
 
you could give your object an ID then find it's top and left position using :

var object = document.getElementById(&quot;idOfMyObject&quot;);
var left = object.offsetLeft;
var top = object.offsetTop; Gary Haran
 
Yeah, I tried that but the value that it returned was alway 1. I couldn't get the real value?!?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top