Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8154407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:20:15+00:00 2026-06-06T16:20:15+00:00

How do I return complete html of a page using jQuery? I cannot do

  • 0

How do I return complete html of a page using jQuery?

I cannot do

return $('html').html()

or

return "<html>" + $("html").html() + "</html>";

because the page might not have html tag in it at all. I cannot use a class or id tag because this is not something that I control and can change. So the use case is if I pass a url I need to return complete html of the page and the page may or may not have html tagin it.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:20:17+00:00Added an answer on June 6, 2026 at 4:20 pm

    For what it’s worth, $("html") will return an element in all sane situations, even if the source document didn’t contain an <html> element. This is because the browser will automatically insert certain required elements (including <html>, <head>, and <body>) into the DOM tree, even if they were not specified in the source document.

    The only exception I can think of (where you wouldn’t get anything from $("html")) would be if you were running JQuery against a DOM tree that isn’t HTML — for instance, if you load JQuery into an SVG document. You’d be crazy to do that, though. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting a one page design using loads of jQuery. I have a
I have implemented a dynamic creation of a HTML table using AJAX. Here's what
MVC 3 VB.NET applicaiton... Using express checkout with html razor view. I have tried
I have an ASP.NET page and some custom class that fetches a specified webpage
I have set up a test page using the PrimeFaces showcase labs code to
return false seems to work in the submitHandler but I'm not sure why. function
Why return type of a method is not considered in method overloading ? Can
I have this method that receives an ID number and downloads an HTML website
I subscribe to the click event on all submit buttons on my page once
I am using Jquery to get googlemap data and load it into a div.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.