Francesco said:
I'd like to flip horizontally an image with JavaScript. Is it
possible?
It is, for example:
function flipImg(img)
{
img.src = "right-left.png";
}
<img src="left-right.png" alt="..."
onmouseover="flipImg(this)">
You might want to try to preload the second image.
It is also possible in JScript. Client-side JScript usually runs in MSHTML
(used e.g. by Internet Explorer) which supports Microsoft Filters:
function flipImgHorz(img)
{
if (img && img.filters && img.filters.item)
{
img.style.filter =
"progid
XImageTransform.Microsoft.BasicImage(mirror=1)";
}
}
<body onload="flipImgHorz(document.images['foo'])"
<img src="left-right.png" alt="..." name="foo">
</body>
However, I recommend to use conditional comments in order to apply the
filter without client-side DOM scripting:
<head>
...
<!--[if IE]>
<style type="text/css">
img#foo {
filter: progid
XImageTransform.Microsoft.BasicImage(mirror=1);
}
</style>
<![endif]-->
</head>
<body>
<img src="left-right.png" alt="..." id="foo">
</body>
HTH
PointedEars