Skip to main content

Bug Tracker

Side navigation

#8096 closed bug (fixed)

Opened January 31, 2011 10:24AM UTC

Closed February 02, 2011 12:23PM UTC

Last modified March 13, 2012 07:08PM UTC

$( html, ownerDocument ) causes "createDocumentFragment is not a function" error

Reported by: scribu Owned by: scribu
Priority: low Milestone: 1.5
Component: core Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

I am trying to create an element inside an iframe, like so:

var $iframe = $('iframe').contents(),
    $el = $('<div>', $iframe);

The second line causes an error in Firefox 3.6 and Chromium:

b.createDocumentFragment is not a function

jquery.min.js (line 120)

I have also tried

$('<div>', $iframe.get())
and got the same result.

For some reason, the iframe Document object does not have that function.

Attachments (0)
Change History (5)

Changed January 31, 2011 10:29AM UTC by scribu comment:1

I should note that the iframe is from the same domain.

I can call

$iframe.find('body').prepend('foo');
just fine.

Changed January 31, 2011 11:02AM UTC by scribu comment:2

_comment0: Found out that this works: \ \ {{{ \ var $iframe = $('iframe').contents(), \ $el = $('<div>', $iframe.get()[0]); \ }}} \ \ Maybe providing an example in the [http://api.jquery.com/jQuery/ documentation] would help others that are stumbling into this.1296472122311959

Found out that this works:

var $iframe = $('iframe').contents(),
    $el = $('<div>', $iframe.get(0));

Maybe providing an example in the documentation would help others that are stumbling into this.

Changed February 02, 2011 02:44AM UTC by jitter comment:3

owner: → scribu
status: newpending

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

Please submit a reduced test case, which reproduces the issue you are experiencing, on http://jsfiddle.net. So that we can investigate this issue further.


How to report bugs

Changed February 02, 2011 05:34AM UTC by scribu comment:4

status: pendingnew

Here you go:

http://jsfiddle.net/98E97/4/

It seems to be fixed in jQuery 1.5. Please close this ticket.

Changed February 02, 2011 12:23PM UTC by jitter comment:5

component: unfiledcore
milestone: 1.next1.5
priority: undecidedlow
resolution: → fixed
status: newclosed

Closing as reporter confirmed its fixed in current version.