如何在Javascript中获取URL的DOM(文档)?

时间:2015-07-10 14:49:25

标签: javascript dom phantomjs

我想做这样的事情:

authnRequest.setSignature(signature);

((SAMLObjectContentReference)signature.getContentReferences().get(0))
           .setDigestAlgorithm(EncryptionConstants.ALGO_ID_DIGEST_SHA256);

是否可以或应该在浏览器中打开页面(PhantonJS)?

1 个答案:

答案 0 :(得分:0)

试试这个

function loadFileToElement(filename, elementId)
{
    var xhr = new XMLHttpRequest();
    try
    {
        xhr.open("GET", filename, false);
        xhr.onload = function () {
            var com = document.getElementById(elementId);
            com.innerHTML = xhr.responseText;
        }
        xhr.send();
    }
    catch (e) {
        window.alert("Unable to load the requested file.");
    }
}