SVG <a> tags don't work in Safari

匿名 (未验证) 提交于 2019-12-03 02:33:02

问题:

The <a> tags inside my svg link perfectly to my modals in Google Chrome. However, in Safari the links do not work. I thought it was a modal issue, but I tested opening a separate modal and it worked. I think the problem lies in the svg, but I just can't get it to work. Any help would be much appreciated.

SVG html

<object>     <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1190px" height="1261px" viewBox="0 0 1190 1261" enable-background="new 0 0 1190 1261" xml:space="preserve">         <a href="#openRoom4_1">             <polygon class="roomSVGs" fill="blue" points="626,259 827,324 980,191 775,137   "/>         </a>     </svg> </object> 

Modal html

        <div id="openRoom4_1" class="modalDialog">             <div class="roomModal">                 <a href="#close" title="Close" class="close">&times;</a>                 <h2>Room 4.1</h2>                    <p>Hi</p>             </div>         </div> 

回答1:

Safari doesn't support href, you'd need to use xlink:href if you want things to work there.

xlink:href is SVG 1.1, href is an SVG 2 feature.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!