See this example .
The code inside svg looks like this:
document.getElementById("svgroot").addEventListener("click", sendClickToParentDocument, false); function sendClickToParentDocument(evt) {
And in the parent document, you have a script with the function you want to call, for example:
function svgElementClicked(theElement) { var s = document.getElementById("status"); s.textContent = "A <" + theElement.nodeName + "> element with id '" + theElement.id + "' was clicked inside the <" + theElement.ownerDocument.defaultView.frameElement.nodeName.toLowerCase() + "> element."; }
source share