Thomas Meinike: Elementknoten aus anderem Frame kopieren

Beitrag lesen

Hallo,

Gibt es eine Möglichkeit, einen Elementknoten aus einem anderen Frame zu kopieren (document.cloneNode(Knoten, true) schlägt fehl,

Im IE schlaegt das fehl, unter Mozilla dagegen nicht. Im IE hilft aber outerHTML. Hier mal ein Testcase (funktioniert mit Mozilla 1.x, Opera 7.x, IE 5.5, 6.0):

[frameset_a_b.htm]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<title>Test by TM 01/04</title>
</head>
<frameset cols="200,*">
<frame src="fra.htm" name="fra">
<frame src="frb.htm" name="frb">
<noframes>
<body>
<p>Mach was draus ...</p>
</body>
</noframes>
</frameset>
</html>

------------------------------------------------------------------------------------------------------------

[fra.htm]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test by TM 01/04</title>
<script language="JavaScript" type="text/javascript">
<!--

function cloneYourLover()
{
  var obj,clone;
  obj=document.getElementsByTagName("p").item(0);
  clone=obj.cloneNode(true);
  if(parent.frames["frb"].document.body.outerHTML)
  parent.frames["frb"].document.body.insertAdjacentHTML("beforeEnd",obj.outerHTML);
  else parent.frames["frb"].document.body.appendChild(clone);
}

//-->
</script>
</head>
<body>
<form action="">
<input type="button" value="Clone your lover" onclick="cloneYourLover()">
</form>
<p>Lover</p>
</body>
</html>

------------------------------------------------------------------------------------------------------------

[frb.htm]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test by TM 01/04</title>
</head>
<body>
<p>Your cloned ...</p>
</body>
</html>

MfG, Thomas

--
SVG - Learning By Coding
http://svglbc.datenverdrahten.de/