kaszu wrote:Please explain what you are trying to achieve, why you need HEAD of the received document (already posted how to get title of received document)?
What I'm trying to achieve: create a jquery object that contains all elements in an entire HTML document. Why? This way I can XHR for html documents and have my script dynamically react to the various elements (title, meta, body's content, anything).
What you posted on how to get the title, doesn't work. The following is the steps I took to test out your example.
- I went to http://google.com.
- Sense I'm using Chrome on Windows, I pressed Ctrl+Shift+J to open the web inspector and console.
- I clicked a bookmarklet I made which imports jQuery into anypage.
- I typed the following into the console (comments are console logs):
Code: Select all
var doc;
// undefined
$.get("/", function(html) { doc = html });
// XMLHttpRequest
$("<div></div>").append(doc);
// x Uncaught TypeError: Cannot call method 'appendChild' of undefined
As you can see from my test, the console is spitting out an error when I try to append the document to a newly created div.
kaszu wrote:DIV will have all children of HEAD and BODY, but not these two elements (there will be TITLE, META, LINK, SCRIPT, DIV, A, ..., but not BODY and HEAD).
Maybe, if I could get it to work.
kaszu wrote:By "content" I mean "a portion of html from BODY".
I assumed as much.