admin管理员组文章数量:1023273
I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="" xmlns:xsd="" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="http://www.w3/2001/XMLSchema-instance" xmlns:xsd="http://www.w3/2001/XMLSchema" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
Share Improve this question edited Jul 11, 2013 at 15:06 Sam asked Jul 11, 2013 at 14:12 SamSam 14.6k32 gold badges114 silver badges203 bronze badges 2-
For IE I think you will need to bounce it back to the server. There is
window.open('javascript:document.write("' + "hello" + '")');
but I think you will have issues getting it to work with xml – Alex K. Commented Jul 11, 2013 at 14:28 - docuemnt.write implies that I format the xml by myself. I want to let the browser do that. Sounds like a pain indeed.... – Sam Commented Jul 11, 2013 at 14:44
2 Answers
Reset to default 4From the data Protocol article in the MSDN library:
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements.
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements...
They can with this Javascript trick..
var uri = 'data:text/xml,' + encodeURIComponent({your xml});
var link = document.createElement("a");
link.href = uri;
link.style = "visibility:hidden";
link.download = fileName + ".xml";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="" xmlns:xsd="" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
I've done the following to display my xml into a new browser window:
window.open('data:text/xml,' + encodeURIComponent( '<?xml version="1.0" encoding="utf-8"?><Document xmlns:xsi="http://www.w3/2001/XMLSchema-instance" xmlns:xsd="http://www.w3/2001/XMLSchema" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><parent>test</parent></Document>' ));
works great in all browsers... but IE obviously. I'm using IE10. What should I do to get this to work ? Right now, the xml is URL encoded and does not show up in the new window.
Share Improve this question edited Jul 11, 2013 at 15:06 Sam asked Jul 11, 2013 at 14:12 SamSam 14.6k32 gold badges114 silver badges203 bronze badges 2-
For IE I think you will need to bounce it back to the server. There is
window.open('javascript:document.write("' + "hello" + '")');
but I think you will have issues getting it to work with xml – Alex K. Commented Jul 11, 2013 at 14:28 - docuemnt.write implies that I format the xml by myself. I want to let the browser do that. Sounds like a pain indeed.... – Sam Commented Jul 11, 2013 at 14:44
2 Answers
Reset to default 4From the data Protocol article in the MSDN library:
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements.
For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements...
They can with this Javascript trick..
var uri = 'data:text/xml,' + encodeURIComponent({your xml});
var link = document.createElement("a");
link.href = uri;
link.style = "visibility:hidden";
link.download = fileName + ".xml";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
本文标签: javascript using data uri to show xml streamStack Overflow
版权声明:本文标题:javascript: using data uri to show xml stream - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745598657a2158323.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论