Anonymous
06-17-2004, 01:34 PM
I was looking at this example using events (code at the bottom) and it works.
I try to use it in another html file with checkboxes, and it doesn't work. I tried to have the checkbox call a function and pass in the checkbox and evt. Upon loading I get an error "evt not defined" or something to that effect. When can you use evt?
================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg contentScriptType="text/ecmascript" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
<script>
function fill_rects(evt, color)
{
nodes = evt.currentTarget.getElementsByTagName("rect");
for(i=0; i!=nodes.length; i++) // strangely does not work with "smaller than"
nodes.item(i).setAttributeNS(null,'fill',color);
}
</script>
<g onmouseover="fill_rects(evt,'yellow')" onmouseout="fill_rects(evt,'red')" fill="red">
<rect x="20" y="330" width="150" height="100"/>
<rect x="200" y="330" width="150" height="100"/>
<rect x="380" y="330" width="150" height="100"/>
</g>
</svg>
I try to use it in another html file with checkboxes, and it doesn't work. I tried to have the checkbox call a function and pass in the checkbox and evt. Upon loading I get an error "evt not defined" or something to that effect. When can you use evt?
================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg contentScriptType="text/ecmascript" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify" contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
<script>
function fill_rects(evt, color)
{
nodes = evt.currentTarget.getElementsByTagName("rect");
for(i=0; i!=nodes.length; i++) // strangely does not work with "smaller than"
nodes.item(i).setAttributeNS(null,'fill',color);
}
</script>
<g onmouseover="fill_rects(evt,'yellow')" onmouseout="fill_rects(evt,'red')" fill="red">
<rect x="20" y="330" width="150" height="100"/>
<rect x="200" y="330" width="150" height="100"/>
<rect x="380" y="330" width="150" height="100"/>
</g>
</svg>