Bug Tracker

Modify

Ticket #10986 (closed feature: invalid)

Opened 19 months ago

Last modified 19 months ago

Full page source

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

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.

Change History

comment:1 Changed 19 months ago by matjaz.horvat@…

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>";

comment:2 Changed 19 months ago by sindresorhus

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to misc

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 );

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.