HTML and CSS Reference
In-Depth Information
(continued)
If these two lines are added to your hosts file, then browsing to either http://
myfirstfakedomain.com or http://myotherfakedomain.com will direct a request
to a web server running on your local machine.
To experiment with cross-domain messaging, you'll need two files. The
first, the parent page, contains an <iframe> element that will load the
second child page:
<iframe width="600px"
height="200px" src="child-1.html">
</iframe>
<textarea id="message">
This is a message in
the parent frame
</textarea>
This page also contains a <button>
that will initiate communication
with the child:
<button onclick="update_child()">
Update child
</button>
The update_child() function attempts to directly edit the contents of the
child page:
function update_child() {
var el = document
.getElementsByTagName(
'iframe'
)[0];
var tb = el.contentDocument
.getElementById('message');
tb.value = 'Updated from parent';
}
Search WWH ::




Custom Search