Rob*_*son 12
检查UA是否支持http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow功能字符串,如果有,则显示SVG textArea,否则在foreignObject内显示html textarea,例如
<switch>
<g requiredFeatures="http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow">
<textArea width="200" height="300">whatever</textArea>
</g>
<foreignObject width="200" height="300">
<textArea xmlns="http://www.w3.org/1999/xhtml" style="width: 200px;height: 300px">otherwise</textArea>
</foreignObject>
</switch>
Run Code Online (Sandbox Code Playgroud)