【发布时间】:2009-03-20 05:20:05
【问题描述】:
我正在尝试使用内容协商在 HTTP 服务器上提供资源的 HTML 和 RDF/XML 表示。在服务器端这是有效的,即
curl -H "Accept: application/rdf+xml" http://localhost:8182/ontologies/1
将检索正确的版本。我也可以用 JavaScript/Dojo 做同样的事情:
function downloadOntologyRDF(ontologyId) {
dojo.xhrGet( {
url:"${baseUrl}/ontologies/" + ontologyId,
headers: {"Accept": "application/rdf+xml"},
timeout: 5000,
load: function(response, ioArgs) {
var preNode = document.createElement("pre");
preNode.appendChild(document.createTextNode(response));
var foo = new dijit.Dialog({
title: "RDF",
content: preNode,
style: "overflow: auto;"
});
foo.show();
return response;
},
error: function(response, ioArgs) {
alert("Retrieving the RDF version failed: " + response);
return response;
}
});
}
这将在弹出对话框中显示结果。我被卡住的地方是为用户提供了一种下载此版本的方法。我想在页面上有一个链接,可以在浏览器中将 RDF 显示为页面或直接打开保存对话框。在不借助查询参数或其他技巧的情况下,这是否可能?
【问题讨论】:
-
我怀疑除了查询参数之类的服务器端东西之外别无他法
标签: browser download mime-types content-negotiation