MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See for all notifications.

Your Search Results

    Parsing HTML From Chrome

    この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。

    Chrome  25.0.1364.5 dev. At least some well formed HTML can be parsed by lying about the MIMEtype thus:

    var doc = parser.parseFromString(html, "text/xml");

    Using "text/html" always returns null, even if the the html is correct and simple, eg

    new DOMParser().parseFromString("<html><head></head><body></body></html>", "text/html");

    The form:

     var doc = document.implementation.createHTMLDocument("");
     doc.body.innerHTML = html;

    seems to work fine for one case I tried. I guess it should work well in general.


    Contributors to this page: Hsivonen, Shaver, JohnJBarton1, Nickolay, Noitidart, MykMelez
    最終更新者: Noitidart,