Doctype problem displaying SVG with Safari

前端 未结 2 879
南旧
南旧 2020-12-12 04:35

I have several SVG images I\'d like to layout on a page. Firefox and Chrome have given me no issues whatsoever, but Safari only seem to display the SVG image if and only if

相关标签:
2条回答
  • 2020-12-12 04:55

    The reason .xhtml works in Safari and .html doesn't is that Safari needs to treat the document as XML to allow embedded SVG. The latest versions of Firefox and Chrome use a HTML5 parser which allows SVG to be embedded in plain HTML documents, so they should work with both.

    To have it render properly in Safari you need to set the content type to application/xhtml+xml. Use this in your PHP file before you output any content:

    <?php
    header('Content-type: application/xhtml+xml');
    ?>
    
    0 讨论(0)
  • 2020-12-12 05:12

    you can set your php config to process xhtml files.

    In this example I'm assuming you're using apache on debian/ubuntu

    you can look in the file /etc/apache2/mods-enabled/php5.conf

    <IfModule mod_php5.c>
    
    <FilesMatch "\.xhtml$">
    SetHandler application/x-httpd-php
    </FilesMatch>
    
    </IfModule>
    

    You may have this SetHandler directive in some other file if you're using a different webserver or distro or OS...

    assuming you're on a unix box, just grep the /etc/apache or /etc/httpd directories

    grep -Ri sethandler /etc/apache
    
    0 讨论(0)
提交回复
热议问题