tags:

views:

85

answers:

3

Dear users,

I have an overlay image that is created in Javascript using the 'Createelement' function. Now I would like to know if I can attach a handler to the mouseover event using PHP?

Can you give an example pls?

The image appears only when hovering over the element below it.

Regards, T

UPDATE I want to handle the mouseover event of that element with PHP on server side. Just cause the whole site I'm editing is coded in PHP. The problem is that all HTML/CSS & JS is generated by PHP code of this site, so I'm thinking using PHP will be easier.

What will the effects of that be on the user though, speed etc?

UPDATE2: So the image that I want to add this handler to, only appears when the mouse is hovered over the image below. Now, when one then hovers over that hovering image, it flickers. I'm trying to suppress the 'mouseover' event of that hovering image so it doesn't reload when hovered over, and so stops flickering.

A: 

Here is an example:

var elem = document.createElement("…");
elem.onmouseover = function() {
    // your mouseover code
};
Gumbo
A: 

PHP can't directly handle things that happen on the client side. So, to handle a mouseover w/ PHP, you have two options:

1) make an AJAX call on the mouseover event, handle it there.

or

2) have the PHP code echo javascript code.

if you can explain more clearly what you are trying to accomplish, that may help. one (or both) of these suggestions may not be applicable.

GSto
Tony
yes, but I am confused as to why you are trying to handle this with PHP. It's not possible. The closest you will get to that is echoing javascript code with PHP. Your best bet would be to do it in javascript.
GSto
A: 

If your goal is to stop the overlay image from flickering, that can be achieved client-side (in JS) without any server-side work (in PHP).

If you provide a URL that demonstrates the flickering behavior, we'll have some chance of helping solve the problem.

jhurshman