このソリューションはimg要素用です
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body {
background:#0000FF;
}
</style>
<script type="text/javascript" language="javascript" src="jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="DD_belatedPNG_0.0.8a.js"></script>
<script>
$(document).ready(function () {
function imageClickHandler () {
var $newA = $("<a></a>")
var $newImg = $(this).find('img').clone(false,false);
$newImg.attr("style","");
$newA.append($newImg);
$newA.click(imageClickHandler);
$(this).parent().append($newA);
DD_belatedPNG.fix('img');
}
DD_belatedPNG.fix('img');
$('a').click(imageClickHandler);
});
</script>
</head>
<body>
<a><img src="image.png" /></a>
</body>
</html>
このソリューションを編集
するのはbg要素用です
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body {
background:#0000FF;
}
a {
display:inline-block;
//display:inline;
zoom:1;
width:512px;
height:512px;
background:url(image.png) no-repeat center center;
text-decoration:none;
outline:none;
}
</style>
<script type="text/javascript" language="javascript" src="jquery.min.js"></script>
<script type="text/javascript" language="javascript" src="DD_belatedPNG_0.0.8a.js"></script>
<script>
$(document).ready(function () {
function imageClickHandler () {
var $newA = $(this).clone(false,false);
$newA.removeAttr("style isImg vmlInitiated vmlBg");
$newA.click(imageClickHandler);
$(this).parent().append($newA);
DD_belatedPNG.fix('a');
}
DD_belatedPNG.fix('a');
$('a').click(imageClickHandler);
});
</script>
</head>
<body>
<a></a>
</body>
</html>