objects in a document inside iframe are not accessible right after the frame is moved using DOM methods

UNCONFIRMED
Unassigned

Status

()

Core
DOM
UNCONFIRMED
12 years ago
9 years ago

People

(Reporter: Jan Jaap Hakvoort, Unassigned)

Tracking

({testcase})

Trunk
x86
Windows XP
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(4 attachments)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7

Hi!

This is a really anoying bug, IFRAMES will be disabled when moved via Javascript DOM. In some setups, it will work 1 time but the iframe will be disabled after the second move. In other setups the IFRAME is always disabled after a move.

You can test here: http://testforum.obeyon.com/

Reproducible: Always

Steps to Reproduce:
1. move the container of an IFRAME or IFRAME element itself via DOM, the IFRAME will then not be accessable anymore via javascript (e.g. WYSIWYG editors won't work anymore)
Actual Results:  
IFRAME disabled (for javascript)

Expected Results:  
IFRAME disabled (for javascript)

There are more bug reports from other users with whom I've spoken, this is a bug wich should be fixed a.s.a.p.!!!

Comment 1

12 years ago
Can you give more precise steps to reproduce?  Is there a button in that page I can press that moves the designMode iframe around in the DOM?
(Reporter)

Comment 2

12 years ago
Hi!

First of all, this bug occurs always in any designMode. The designMode has nothing to do with this bug.

For example, if you do this:

// iframe.html
<html>
<head>
<script type="text/javascript">
function test_function(move_text) {
alert('iframe accessed '+move_text);
}
</script>
</head>
<body>
Iframe access test
</body>
</html>

// test.html
<html>
<head>
<script type="text/javascript">
function onload_set_iframe() {
window["iframe_container"] = document.getElementById('iframe_container');
}
var active_container = 1;
function move_test_iframe() {
if (document.frames) {
	var IFrameObj = document.frames['the_iframe'];
} else {
	var IFrameObj = self.the_iframe;
}
IFrameObj.test_function('before move');

if (active_container==1) {
var target = document.getElementById('iframe_container_container_2');
target.appendChild( window["iframe_container"] );
active_container = 2;
IFrameObj.test_function('after move');
} else {
var target = document.getElementById('iframe_container_container_1');
target.appendChild( window["iframe_container"] );
active_container = 1;				
IFrameObj.test_function('after move');
}
}
</script>
</head>
<body onload="onload_set_iframe();">
Iframe Container 1
<div id="iframe_container_container_1" style="border:dotted 1px red;">
<div id="iframe_container">
<iframe src="iframe.html" id="the_iframe" name="the_iframe"></iframe>
</div>
</div>
<hr>
Iframe Container 2
<div id="iframe_container_container_2" style="border:dotted 1px lime;">

</div>
<hr>
<a href="javascript:move_test_iframe();">Move & test Iframe</a>
</body>
</html>

With this code, the iframe will be disabled after the first move! But I managed to get it working for 1 move before, just don't remember how anymore.

Comment 4

12 years ago
Thanks for the testcase. So the problem is that the function declared in the iframe cannot be called after moving it?
Severity: critical → normal
Version: unspecified → Trunk

Comment 5

12 years ago
Dup of bug 254144?
(Reporter)

Comment 6

12 years ago
Hi!

It's simular but these bug reports together show the real issue, the Iframe is lost after moving it. So the issue is not only "the refresh after moving the iframe" or "javascript functions not accessible after moving the iframe" but that the iframe is lost after moving it via DOM.

Best Regards,
Jan Jaap Hakvoort
(Reporter)

Comment 7

12 years ago
(In reply to comment #4)
> Thanks for the testcase. So the problem is that the function declared in the
> iframe cannot be called after moving it?


Hi!

Yes, that's the problem. You can test the test javascript in IE and see how it should work. You will get 2 alert boxes with each move (before move and after move). In FireFox it doesn't work anymore after the move. It's weird that it hasn't been fixed yet, since I would aspect a lot of developpers are using dynamic Iframes especialy with the Wysiwyg editors wich also use an iframe.

Best Regards,
Jan Jaap Hakvoort

Comment 8

12 years ago
Created attachment 241322 [details]
frame document for the testcase

Comment 9

12 years ago
Created attachment 241323 [details]
testcase

Comment 10

12 years ago
Thanks. I believe this is actually a dupe of bug 254144. The objects in the iframe are not accessible right after the iframe is moved because the document in the iframe has not yet finished (re)loading by that time. If you try accessing them again later, everything will work fine.

(On slower connections, you might need to select Work offline before clicking "Test" in the testcase)
Keywords: testcase
Summary: IFRAME DISABLED WHEN MOVED VIA DOM → objects in a document inside iframe are not accessible after the frame is moved using DOM methods

Updated

12 years ago
Component: General → General
Product: Firefox → Core
QA Contact: general → general
Summary: objects in a document inside iframe are not accessible after the frame is moved using DOM methods → objects in a document inside iframe are not accessible right after the frame is moved using DOM methods

Comment 11

12 years ago
Gah, sorry for the multiple mails. Please resolve appropriately if you agree this is a dupe.
Assignee: nobody → general
Component: General → DOM
QA Contact: general → ian
(Reporter)

Comment 12

12 years ago
Hi!

I already tried adding a setTimeout("xxx",10000); to access the IFRAME but that does NOT work!

Your test does not move the iframe so I don't understand why you posted it.

Best Regards,
Jan Jaap Hakvoort
(Reporter)

Comment 13

12 years ago
p.s. wouldn't it be better to have the content of the iframe remain intact when you move it? Imagine if you want to move user generated content inside an iframe, it won't be possible in Firefox...

Comment 14

12 years ago
> I already tried adding a setTimeout("xxx",10000); to access the IFRAME 
> but that does NOT work!

You're right, sorry. The problem is, you're getting the [object Window] for the frame's document, which goes away as the frame reloads. So naturally accessing it doesn't work even after timeout. If you do |IFrameObj = document.getElementById("the_iframe").contentWindow| before using it in the timeout, everything will work.

Interestingly, just repeating |IFrameObj = self['the_iframe'];| doesn't set IFrameObj to point to correct [object Window].

> Your test does not move the iframe so I don't understand why you posted it.

What's relevant is that the element is removed from the DOM and reinserted back. My testcase does that. The actual position in the tree does not matter.

> p.s. wouldn't it be better to have the content of the iframe remain intact
> when you move it? Imagine if you want to move user generated content 
> inside an iframe, it won't be possible in Firefox...

Sure, I'm not arguing against that, but it's what bug 254144 is about, and I was trying to figure out if your issue is caused by the same bug.

Comment 15

12 years ago
*** Bug 351333 has been marked as a duplicate of this bug. ***

Comment 16

12 years ago
Created attachment 241328 [details]
frame document for testcase #2

Comment 17

12 years ago
Created attachment 241329 [details]
testcase #2 - self.frame_name doesn't get updated to point to the new window

Comment 18

12 years ago
(comment #14)
> Interestingly, just repeating |IFrameObj = self['the_iframe'];| doesn't set
> IFrameObj to point to correct [object Window].
> 
The above testcase demonstrates this, tested in Firefox 2.
Assignee: general → nobody
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.