Skip to main content

Bug Tracker

Side navigation

#10986 closed feature (invalid)

Opened December 09, 2011 01:00PM UTC

Closed December 09, 2011 01:48PM UTC

Full page source

Reported by: matjaz.horvat@gmail.com Owned by:
Priority: low Milestone: None
Component: misc Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

There is currently no easy way of displaying full website source (rendered). Of course, one can use $("html").html(), but in this case DOCTYPE and <html> tag are omitted.

Attachments (0)
Change History (2)

Changed December 09, 2011 01:04PM UTC by matjaz.horvat@gmail.com comment:1

To display full page source, currently one has to do something like this:

var dt = document.doctype,
    public = (dt.publicId) ? ' PUBLIC "' + dt.publicId + '"' : "",
    system = (dt.systemId) ? ' "' + dt.systemId + '"': "",
    doctype = '<!DOCTYPE ' + dt.name + public + system + '>',
    html = '<html';

    $($("html")[0].attributes).each(function() {
       html += ' ' + this.name + '="' + this.nodeValue + '"';
    });
    
var fullSource = doctype + "\\n" + html + ">\\n" + $("html").html() + "\\n</html>";

Changed December 09, 2011 01:48PM UTC by sindresorhus comment:2

component: unfiledmisc
priority: undecidedlow
resolution: → invalid
status: newclosed

This is a bug tracker, not a forum. Try asking in the jQuery forum or on StackOverflow.

You could do something like this:

console.log(  '<!doctype html>' + document.documentElement.outerHTML );