I want to access VML element which stores fill image in VML. I pasted my demo code below. Notice that it will only work when you include raphael.js and jquery.js.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Raphael Test</title>
<script type="text/javascript" src="js/libs/jquery.js"></script>
<script type="text/javascript" src="js/libs/raphael.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var raphael, path, pattern;
raphael = Raphael(document.getElementById('raphael'), 500, 500);
path = raphael.circle(100, 100, 80);
path.attr('stroke-width', 3);
path.attr('fill', 'url(http://3.bp.blogspot.com/_M4WdA9j-b-g/TLMF9JJJwcI/AAAAAAAAAV4/p0Y_Wo3S3sQ/s1600/Landscape1.jpg)');
pattern = $(path.node).attr('fill');
if(pattern) {
pattern = pattern.replace('url(', '').replace(')', '');
pattern = $(pattern);
}
// Shape element documentation: http://msdn.microsoft.com/en-us/library/hh846327(v=vs.85).aspx#shape_element
// Fill element documentation: http://msdn.microsoft.com/en-us/library/bb229596(v=vs.85).aspx
if(Raphael.vml) { // SVG not supported (IE7 & IE8) and it doesn't work :/
console.log($(path.node).find('fill').attr('href'));
}
else { // SVG supported and it prints correct URL
console.log($(pattern).find('image').attr('href'));
}
});
</script>
</head>
<body>
<div id="raphael"></div>
</body>
</html>
In SVG fill image is provided using pattern element. That's why I'm fetching this element, and I can easily access its href attribute.
VML is pretty different. Path is created with shape element, which have fill element inside. But unfortunately fill element doesn't have any attributes:/
Can someone help me to access VML fill image element?