0
私は、人がWebフォーム経由で編集を終えた後にsvgファイルを.svgファイルに保存しようとしています。私は.pngまたは.jpgとして保存したくありません。私は.innerHTMLを取得し、.svgとして保存するために次のコードを使用しようとしましたが、.innerHTMLを使用してオブジェクトタグに何も見つかりません。埋め込みオブジェクトからsvgを保存する
<div class="images">
<div id="fixed-column" class="id-column" style="margin-bottom: 15px; display: inline-block;">
<div id="summary1" class="summary" style="margin-top: 0px; width: 100%;">
<div id="idbox"><object id="statephoto" class="imageplacement" data="/id-photos/al.svg" type="image/svg+xml" name="image-swap" width="100%" min-height="150"></object></div>
</div>
<div class="id-instuctions">Fill out the form to start you custom pet tag design!!</div>
</div>
</div>
<a href="#" id="downloadLink">Download the inner html of #main</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"> </script>
<script>
function downloadInnerHtml(filename, elId, mimeType) {
var elHtml = document.getElementById('statephoto').innerHTML;
var link = document.createElement('a');
mimeType = mimeType || 'text/plain';
link.setAttribute('download', filename);
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}
var fileName = 'tags.svg'; // You can use the .txt extension if you want
$('#downloadLink').click(function(){`enter code here`
downloadInnerHtml(fileName, 'main','svg/xml');
});