Getting IFRAME Window (And Then Document) References With contentWindow

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Getting IFrame Window Reference With contentWindow</title>
	<script type="text/javascript" src="jquery-1.3.2.js"></script>
	<script type="text/javascript">
 
		// When the document has loaded, add an iFrame.
		$(
			function(){
				var jFrame = $( "<iframe name='my-frame'>" );
				var objDoc = null;
 
				// Set frame properties and add it to the body.
				jFrame
					.css( "width", "400px" )
					.css( "height", "100px" )
					.appendTo( $( "body" ) )
				;
 
				// Now, we are going to use two methods for getting
				// the iFrame window reference and thereby the
				// document reference such that we can write to it.
 
				// Use FRAMES array:
				objDoc = window.frames[ "my-frame" ].document;
 
				objDoc.write( "Gotten via FRAMES <br />" );
 
				// Use the contentWindow property of the iFrame.
				objDoc = jFrame[ 0 ].contentWindow.document;
 
				objDoc.write( "Gotten via contentWindow <br />" );
 
				// Close the document.
				objDoc.close();
			}
			);
 
 
	</script>
</head>
<body>
 
	<h1>
		Getting IFrame Window Reference With contentWindow
	</h1>
 
	<p>
		An iFrame will be added below this:
	</p>
 
</body>
</html>

For Cut-and-Paste