Ticket #5579 (closed bug: wontfix)
iframe with name="body" blows up at ready() time
| Reported by: | replaid | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | support | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
The following HTML page throws a script error in Safari 4.0.3. If a ready() function is added it will not run.
The error message is: TypeError: Result of expression 'document.body.appendChild' [undefined] is not a function. ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js:3204
Here's the smallest HTML code to reproduce the problem:
<script type="text/javascript" src=" http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <iframe name="body"></iframe>
Change History
comment:2 Changed 4 years ago by replaid
I agree with dmethvin's comment, except that I think jQuery should at least be able to operate in that situation. Right now it can't run any $(document).ready() functions at all if such a frame exists!
comment:3 Changed 3 years ago by dmethvin
- Component changed from unfiled to support
line 3204 is in jQuery.support
comment:4 Changed 3 years ago by dmethvin
Hmmm, perhaps we could use document.getElementsByTagName(‘body’)[0] instead?
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This might be a manifestation of the problem seen in #3113 with forms. The expression document.body becomes ambiguous and either refers to the body element or the iframe with a name of "body". Not sure if jQuery can do anything about it though.