#3409 closed bug (invalid)
Can't get HEAD element from an AJAX return
Reported by: | Just | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | Just, flesler | |
Blocked by: | Blocking: |
Description
Using this <js>alert($('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Test</title></head><body>InnerHTML\'s body</body></html>').html());</js>
It display me "Test". So the TITLE element's content. Can't get any one of the HTML, HEAD or BODY element. Can access the element in the BODY element but not those which is in the HEAD element.
Change History (7)
comment:1 Changed 15 years ago by
Cc: | Just flesler added |
---|---|
Owner: | set to john |
comment:2 Changed 15 years ago by
comment:4 Changed 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
You can't swallow a whole html document with $("html")
; whatever you pass in as a string has to be valid within a div:
http://docs.jquery.com/Core/jQuery#htmlownerDocument
As an alternative, you could use an XML parser ouside of jQuery if the markup is valid XML and pass that to $()
instead.
comment:6 Changed 12 years ago by
FWIW, I've written a plugin called jQuery htmlDoc that attempts to address this issue. It probably needs more testing, but in my basic tests it works well:
All the element is finally put "the one after the other". Just removing the HTML, HEAD, and BODY elements. so that html
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><title>Test</title></head><body>InnerHTML\'s body</body></html>
looks like this
<title>Test</title>InnerHTML\'s body