Closed Bug 436505 Opened 16 years ago Closed 16 years ago

replace contents of a div containing an iframe with innerhtml iframe reference is lost

Categories

(Firefox :: General, defect)

x86
Windows Vista
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 427254

People

(Reporter: alistair_milne, Unassigned)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0; InfoPath.2)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14

This problem occurs when you dynamically replace the contents of a div conating an iframe on the second occurance you can no longer reference the iframe using the frames collection. This means window.frames['framename'].location.replace can no longer be used this is a serious problem as the history can no longer be managed. This only occurs after the div has been redfined with innerhtml the second time.

Reproducible: Always

Steps to Reproduce:
1.see html included
2.
3.
Actual Results:  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
   <script>
   function hello()
     {
 
     window.frames['test'].location.replace('hello.htm')
   }
   function goodbye()
     {
      document.getElementById('test').src="goodbye.htm"
   }   
   function repaintTable()
     {
     document.getElementById("container").innerHTML='<table id="testtable" ><tr><td><iframe id="test" name="test" src="problem.htm"></iframe></td></tr></table>'
   }  
   </script> 
</head>
<body><div id=container>
<table id="testTable">
<tr><td><iframe id="test" name="test" src="hello.htm"></iframe></td>
</tr></table>
</div>
<span onclick="hello()">Click me for hello</span>
<span onclick="goodbye()">Click me for goodbye</span>
<span onclick="repaintTable()">Click me twice for problem</span>
</body>
</html>

Expected Results:  
crashes after second click

here is the content of the other htm files
hello.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body><span>hello</span>
</body>
</html>

goodbye.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>goodbye</title>
</head>
<body><span>goodbye</span>
</body>
</html>

problem.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body><span>Now try hello again</span>
</body>
</html>
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.