How to dom click on IMG the uses MAP ?



Hi

I have a page with IMG that uses map. I want to imitate the action of
a user clicking on that image, in specific coordinates.

The "short" version of the page is here:
---------------
function hh (element){
var str = el.tagName + " - " + window.event.type + ":" +
window.event.button + " "
+ window.event.x + "," +
window.event.y + " "
+ window.event.offsetX + ","
+ window.event.offsetY
globalstr +=str;
}
...
...
<map name="mymap" ... onclick="hh(this)" onmousedown="hh(this)"
onmouseup="hh(this)">
<area ...
<area shape="rect" coords="352,40,413,73" href="onchange.html" ..
onclick="hh(this)" onmousedown="hh(this)"
onmouseup="hh(this)">
<area shape="rect" coords="431,39,494,72" nohref onclick="hh(this);
myvariable = 'kuku2';"
onmousedown="hh(this)" onmouseup="hh(this)"
title="YOYO">
<area ...
<area ...
</map>

<img ... usemap="#mymap" onclick="hh(this)" onmousedown="hh(this)"
onmouseup="hh(this)">

-----------

When the USER clicks on the area titled YOYO , I get the following
behavior (and this is the behavior i want to imitate):

just before unloading from this page,The "globalstr" contains this
info:

AREA - mousedown:1 541,405 526,61
MAP - mousedown:1 541,405 526,61
IMG - mousedown:1 541,405 526,61
AREA - mouseup:1 541,405 526,61
MAP - mouseup:1 541,405 526,61
IMG - mouseup:1 541,405 526,61
AREA - click:0 541,405 526,61
MAP - click:0 541,405 526,61
IMG - click:0 541,405 526,61



the "myvariable" variable gets the "kuku2" value due to the
"onclick"...

and then the page navigates to the new location as defined in the
'href" of that area.

***
Now i want to imitate such a click. In my BHO, i have the offset
coordinates I want to click on (on the image) , and also the same
coordinates relative to the client area.

I do the following (I shortened this code to the imporant lines...)

i set the values of the event:
pEvent2_image->putref_srcElement(element);
pEvent2_image->put_button( 1 ); // i set it to 0 for the "on click"
pEvent2_image->put_offsetX(offsetx);
pEvent2_image->put_offsetY(offsety);

and the same for the area event... the same offsetX and offset Y
are entered !!!!!

and then ...

element3_area->fireEvent(onMouseDown, &eventref_area,
&cancellable); // cause the map to get the event aswell
element3_img>fireEvent(onMouseDown, &eventref_img, &cancellable);

element3_area->fireEvent(onMouseUp, &eventref_area, &cancellable);
element3_img->fireEvent(onMouseUp, &eventref_img, &cancellable);

element3_area->fireEvent(onClick, &eventref_area, &cancellable);
element3_img->fireEvent(onClick, &eventref_img, &cancellable);

What i get is the following:
The "myvariable" indeed gets the "kuku2" value, but the problem is
that page does not navigates according to the "href".

The globalstr shows the following:

AREA - mousedown:1 528,63 526,61
MAP - mousedown:1 528,63 526,61
IMG - mousedown:1 541,405 526,61 <--- x, y here
are ok
AREA - mouseup:1 528,63 526,61
MAP - mouseup:1 528,63 526,61
IMG - mouseup:1 541,405 526,61
AREA - click:1 528,63 526,61
MAP - click:1 528,63 526,61
IMG - click:1 541,405 526,61



** Note that the x,y coordinates in "map" and "area" are not as they
should. They should be the same as in IMG.
setting both x, y, and offsetx, offsety does not help.. either the
x,y, are ok and offsetx,y are not, or the opposite.

I'm not sure if this is what causes of the problem....

How can i make the page navigate according to the correct href? (of
course, i cannot change the page, i created a page just to emulate my
problem, what i have is a page on the web, i know how to find an image
in it and i need to click on it in a specific area....

trying to run the "click()" method just navigated to the first href of
the map (of course, i cannot input and coordinates ...)

any help would be appreciated
Noa

.


Loading