Bug Tracker

Ticket #8096 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

$( 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:
Blocking: Blocked by:


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.

Change History

comment:1 Changed 4 years ago by scribu

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

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

comment:2 Changed 4 years ago by scribu

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.

Version 0, edited 4 years ago by scribu (next)

comment:3 Changed 4 years ago by jitter

  • Owner set to scribu
  • Status changed from new to pending

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

comment:4 Changed 4 years ago by scribu

  • Status changed from pending to new

Here you go:


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

comment:5 Changed 4 years ago by jitter

  • Priority changed from undecided to low
  • Resolution set to fixed
  • Status changed from new to closed
  • Component changed from unfiled to core
  • Milestone changed from 1.next to 1.5

Closing as reporter confirmed its fixed in current version.

Note: See TracTickets for help on using tickets.