Skip to content

Instantly share code, notes, and snippets.

@knewter
Created September 8, 2014 16:01
Show Gist options
  • Save knewter/a2805c149f917fb3e7c6 to your computer and use it in GitHub Desktop.
Save knewter/a2805c149f917fb3e7c6 to your computer and use it in GitHub Desktop.
<html>
<head>
<style type="text/css">
rect {
fill: red;
fill-opacity: 0.8;
}
</style>
</head>
<body>
<svg oncontextmenu="sendClickToParentDocument(evt)" overflow="hidden" viewBox="0 0 2560 3300" preserveAspectRatio="xMidYMin slice">
<script type="application/ecmascript">
<![CDATA[
function sendClickToParentDocument(evt)
{
// SVGElementInstance objects aren't normal DOM nodes, so fetch the corresponding 'use' element instead
var target = evt.target;
if(target.correspondingUseElement)
target = target.correspondingUseElement;
// call a method in the parent document if it exists
if (window.parent.handleSvgContextMenu)
window.parent.handleSvgContextMenu(target);
else
alert("foo");
}
]]>
</script>
<defs></defs>
<image fill-opacity="0" stroke="none" stroke-opacity="0" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" x="0" y="0" width="100%" height="100%" preserveAspectRatio="none" xlink:href="http://localhost:8080/USPTO_image_conversion/convert?url=http://pdfpiw.uspto.gov/99/229/086/10.pdf&amp;w=-1"></image>
<rect fill="none" fill-opacity="0" stroke="none" stroke-opacity="0" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" x="572" y="353" width="158" height="25" ry="0" rx="0" class="highlight highlight123"></rect>
</svg>
<script type="text/javascript">
function handleSvgContextMenu(target){
alert("yay");
console.log(target);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment