I started working on a website for a my wifes new business. I'm a developer by trade, but new to using svg interactively in websites.
I made a header with links in inkscape. after some digging I found I could use the svg events to make the separate text objects into interactive links.
My javascript inside the svg file looks like this:
Code: Select all
// mouseOver event handler, where targt is the element in the svg that was interacted with
function mouseOver(targt){
targt.setAttribute('stroke', 'red');
targt.setAttribute('fill', 'red');
}
// mouseOut event handler, where targt is the element in the svg that was interacted with
function mouseOut(targt){
targt.setAttribute('stroke', 'black');
targt.setAttribute('fill', 'black');
}
This will highlight anything whose onMouseOver or onMouseOut looks like
Code: Select all
onmouseover="mouseOver(evt.target);" onmouseout="mouseOut(evt.target)"
For text objects, this works perfectly, but in a browser, the sng fonts looked terrible. After some digging about, I found a solution where converting the font objects to path objects would resolve the issues.
Now the fonts look great on the webpage, but the onchange event is operating one character at a time instead of on each object.
An example has been attached of the svg file menu. The first link was converted to a path, so looks great but the mouseover event is not working correctly. The rest are text and work fine, but look terrible.
Can anyone tell me either how to get my fonts to look good, or alternatively how to get my path style links to behave as expected to mouse events?
Thanks in advance,
alkinnon