javascript - Svg clipPath in AngularJS app with url in hashbang mode -
i use svg clippath
in angularjs project. follow-up-question this question.
let's have svg this:
<svg width="120" height="120" viewport="0 0 120 120" version="1.1" xmlns="http://www.w3.org/2000/svg"> <defs> <clippath id="myclip"> <rect x="10" y="10" width="60" height="60"></rect> </clippath> </defs> <g clip-path="url(#myclip)"> <circle cx="30" cy="30" r="20"/> <circle cx="70" cy="70" r="20"/> </g> </svg>
because use the <base>
element can't use relative paths this
<g clip-path="url(#myclip)">
so have use absolute url + fragment identifier this:
<g clip-path="url(http://example.com/mypage#myclip)">
this works fine in firefox, safari , chrome. have following problems ie:
ie9 doesn't support html5mode use, therefore hashbangs used , absolute url becomes
http://example.com/!#/mypage#myclip
, clippath doesn't work.in ie10 + ie11, when go page containing svg clippath doesn't work, if refresh page works.
any ideas how solve ie problems?
ie9 doesn't support html5mode use, therefore hashbangs used , absolute url becomes http://example.com/!#/mypage#myclip , clippath doesn't work.
use xml:base conditionally set base url ie9:
<g id="xbrowser" clip-path="url(#myclip)"> <circle cx="30" cy="30" r="20"/> <circle cx="70" cy="70" r="20"/> </g> <script type="application/ecmascript"> if ( ("onpropertychange" in document) && !!window.innerwidth) { document.getelementbyid("xbrowser").xmlbase = "http://example.com/!#/mypage" } </script>
in ie10 + ie11, when go page containing svg clippath doesn't work, if refresh page works.
set clippath programmatically ie:
<script type="application/ecmascript"> if (!!window.xpathevaluator === false && !!window.xpathexpression === false) { document.getelementsbytagname("g")[0].clippath = "url('#myclip')" } </script>
references
Comments
Post a Comment