function loadUrlToWebview(webview, url) {
    assert(webview.tagName === 'WEBVIEW');

    var onError = function() {
      webview.src = 'about:blank';
    };

    var setContents = function(contents) {
      webview.src =
          'data:text/html;charset=utf-8,' + encodeURIComponent(contents);
    };

    var xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.setRequestHeader('Accept', 'text/html');
    xhr.onreadystatechange = function() {
      if (xhr.readyState != 4)
        return;
      if (xhr.status != 200) {
        onError();
        return;
      }

      var contentType = xhr.getResponseHeader('Content-Type');
      if (contentType && !/text\/html/.test(contentType)) {
        onError();
        return;
      }

      setContents(xhr.response);
    };

    try {
      xhr.send();
    } catch (e) {
      onError();
    }
  }
/**
   * Load text/html contents from the given url into the given webview. The
   * contents is loaded via XHR and is sent to webview via data url so that it
   * is properly sandboxed.
   *
   * @param {!WebView} webview Webview element to host the terms.
   * @param {!string} url URL to load terms contents.
   */
Load text/html contents from the given url into the given webview. The
contents is loaded via XHR and is sent to webview via data url so that it
is properly sandboxed.

@param {!WebView} webview Webview element to host the terms.
@param {!string} url URL to load terms contents.
Load text / html contents from the given url into the given webview . The contents is loaded via XHR and is sent to webview via data url so that it is properly sandboxed . @param { !WebView } webview Webview element to host the terms . @param { !string } url URL to load terms contents .
function loadUrlToWebview(webview, url) {
    assert(webview.tagName === 'WEBVIEW');
    var onError = function() {
      webview.src = 'about:blank';
    };
    var setContents = function(contents) {
      webview.src =
          'data:text/html;charset=utf-8,' + encodeURIComponent(contents);
    };
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.setRequestHeader('Accept', 'text/html');
    xhr.onreadystatechange = function() {
      if (xhr.readyState != 4)
        return;
      if (xhr.status != 200) {
        onError();
        return;
      }
      var contentType = xhr.getResponseHeader('Content-Type');
      if (contentType && !/text\/html/.test(contentType)) {
        onError();
        return;
      }
      setContents(xhr.response);
    };
    try {
      xhr.send();
    } catch (e) {
      onError();
    }
  }
function loadUrlToWebview ( webview , url ) { assert ( webview . tagName === 'WEBVIEW' ) ; var onError = function ( ) { webview . src = 'about:blank' ; } ; var setContents = function ( contents ) { webview . src = 'data:text/html;charset=utf-8,' + encodeURIComponent ( contents ) ; } ; var xhr = new XMLHttpRequest ( ) ; xhr . open ( 'GET' , url ) ; xhr . setRequestHeader ( 'Accept' , 'text/html' ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState != 4 ) return ; if ( xhr . status != 200 ) { onError ( ) ; return ; } var contentType = xhr . getResponseHeader ( 'Content-Type' ) ; if ( contentType && ! / text\/html / . test ( contentType ) ) { onError ( ) ; return ; } setContents ( xhr . response ) ; } ; try { xhr . send ( ) ; } catch ( e ) { onError ( ) ; } }
Load text/html contents from the given url into the given webview.
Load text / html contents from the given url into the given webview .