I'm having a lot of trouble getting a simple text link to work in IE8 using Raphael. I want text that behaves like a normal link. I've included some code below that I have been playing with.
Do I need to add some element behind the text, a rectangle / bounding box, to handle the mouse? Any ideas? This problem is only in IE8, which as you know, uses VML via Raphael.
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.4.min.js"></script>
<script type="text/javascript" src="js/raphael-min.js" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function () {
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael(10, 50, 420, 400);
var lbl = paper.text(50, 40, 'test').attr( {
"font" : '14px Helvetica, Arial',
stroke : "none",
fill : '#ffffff',
'text-anchor' : 'middle'
});
lbl.node.style.display = 'block';
lbl.node.style.cursor = 'pointer';
lbl.click(function() {
alert('hi'); });
lbl.hover(function() {
document.body.style.cursor = 'hand';
}, function() {
document.body.style.cursor = 'default';
});
}
</script>
</head>
<body style="background-color: #000000;">
<div id="wrapper" style="background-color: #000000;"> </div>
</body>
</html>
var lbl = paper.text(50, 40, 'test').attr( {
font : '14px Helvetica, Arial',
stroke : "none",
fill : '#fff'
}),
blanket = paper.rect().attr(lbl.getBBox()).attr({
fill: "#000",
opacity: 0,
cursor: "pointer"
}).click(function () { alert("hi"); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With