我有一个本地HTML文件,我可以从浏览器(Firefox)访问它。出于安全原因,该页面无法联机。因此无法实现网络服务。
pic bellow是Firefox调试器的错误。
当我尝试访问已经加载的样式表时,它会抛出一个DOMException。
请求xhttp = new XMLHttpRequest();
xhttp.open("GET", filename, false);
xhttp.responseXML;
这里是抛出异常的函数。
`
/**Generate a document part to be shown in HTML-document
*
* @param {XMLDocument} xml VSF file to be transformed.
* @param {XMLDocument} xsl XSLT style sheet being used for the VSF.
* @param {HTMLDocument} document HTML document where the created fragment belongs to.
* @returns {DocumentFragment} The fragment HTML-document.
*/
function createFragSpecification(xml, xsl, document) {
xsltProcessor = new XSLTProcessor();
try {
xsltProcessor.importStylesheet(xsl);
} catch (err) {
console.error(err);
}
return xsltProcessor.transformToFragment(xml, document);
}
`
有没有人知道我的错误在哪里或如何使用xsltProcessor导入样式表(xsl)?
答案 0 :(得分:0)
据我所知并已使用https://github.com/martin-honnen/martin-honnen.github.io/tree/master/js/2018/jsfilesystemaccess中的文件进行测试Mozilla Firefox允许您从同一目录或文件系统的子目录中加载带有XMLHttpRequest的XML或XSLT文档,您可以[&}然而,导航目录结构。因此,除非存在导入或包含尝试从目录结构中进一步加载文件的导入,否则您的代码应该可以正常工作。