Exported Visio SVG hyperlinks opening in right frame

I work with Visio to do flowcharts at work and sometimes the individual steps will have clickable hyperlinks. These flowcharts are then embedded in web pages as SVG objects and the clickable hyperlinks then open within the object frame rather than in the parent object which is a pain.

The following Javascript snippet (using jQuery) straightens this out:

$(window).load(function(){

        var a = document.getElementsByTagName("object");

        for(i=0; i<a.length; i++) {

                var svgDoc = a[i].contentDocument;

                var svgItem = $(svgDoc).find("a");

                svgItem.attr("target", "_parent");

        }

});