Side navigation
#3409 closed bug (invalid)
Opened September 25, 2008 01:00PM UTC
Closed May 14, 2009 02:01AM UTC
Last modified September 07, 2011 08:12PM UTC
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.
Attachments (0)
Change History (7)
Changed September 25, 2008 04:36PM UTC by comment:1
cc: | → Just, flesler |
---|---|
owner: | → john |
Changed September 30, 2008 08:32AM UTC by comment:2
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
Changed October 10, 2008 05:54AM UTC by comment:3
Under safari that mess up !
I can't get head element at all :/.
Changed May 14, 2009 02:01AM UTC by comment:4
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.
Changed December 16, 2010 06:22PM UTC by comment:6
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: