I'm trying to copy information in one iframe to another iframe with javascript. I am using firefox and information from my local domain so there are no security issues. However I'm just not getting it. Somebody please give me some help here, perhaps show me the right tag names. I'm tired of trial and error guessing. Are there any good books that deal with firefox, iframes, javascript, and asynchronous AJAX?
[CODE=html]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<head>
<title>Test1</title>
<meta name="revision" content="$Id: $" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content=""/>
<meta name="descripti on" content=""/>
<link rel="stylesheet " type="text/css" href="/local-stylesheet.css"/>
<script>
function copy_frame(argF rm1, argFrm2) {
//window.frames["ifrm2"].document.body. innerHTML = "<p>hello</p>"; // works, frame has hello
//window.document .body.innerHTML = "<p>hello</p>"; // works, replaces document with hello.
window.document .body = window.frames["ifrm1"].document.body; // this works!
//window.frames["ifrm2"].document.body = window.frames["ifrm1"].document.body; // This causes both to go blank.
}
</script>
</head>
<body>
<div id="insert"></div>
<div id="div4frm1">
<iframe name="ifrm1" id="ifrm1" src="http://www.local.com" >
use firefox
</iframe>
</div>
<div id="div4frm2">
<iframe name="ifrm2" id="ifrm2" src="" >
Get firefox
</iframe>
</div>
<div id="move">
<INPUT TYPE="button" onClick="copy_f rame(ifrm1, ifrm1);" value="copy" ID="b">
</div>
</body>
</html>[/CODE]
[CODE=html]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >
<head>
<title>Test1</title>
<meta name="revision" content="$Id: $" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content=""/>
<meta name="descripti on" content=""/>
<link rel="stylesheet " type="text/css" href="/local-stylesheet.css"/>
<script>
function copy_frame(argF rm1, argFrm2) {
//window.frames["ifrm2"].document.body. innerHTML = "<p>hello</p>"; // works, frame has hello
//window.document .body.innerHTML = "<p>hello</p>"; // works, replaces document with hello.
window.document .body = window.frames["ifrm1"].document.body; // this works!
//window.frames["ifrm2"].document.body = window.frames["ifrm1"].document.body; // This causes both to go blank.
}
</script>
</head>
<body>
<div id="insert"></div>
<div id="div4frm1">
<iframe name="ifrm1" id="ifrm1" src="http://www.local.com" >
use firefox
</iframe>
</div>
<div id="div4frm2">
<iframe name="ifrm2" id="ifrm2" src="" >
Get firefox
</iframe>
</div>
<div id="move">
<INPUT TYPE="button" onClick="copy_f rame(ifrm1, ifrm1);" value="copy" ID="b">
</div>
</body>
</html>[/CODE]
Comment