HTML and CSS Reference
In-Depth Information
command python -m SimpleHTTPServer 8000 to start a server listening on
port 8000.
Step 2: Set up a cross-domain test environment
To experiment with messaging between scripts in different domains, you need to have
multiple domains available. The easiest way to do this is to fake some domains by
editing the hosts file on your computer. On Windows this file is usually found at
C:\Windows\System32\drivers\etc\hosts (note the lack of a file extension; also note that
this is a system file, so run your editor as administrator); on Mac OS X and Linux it'll be
found at /etc/hosts. Opening that file in a simple text editor should reveal some lines like
the following:
127.0.0.1 localhost
Add your fake domains to the end of the line starting 127.0.0.1:
127.0.0.1 localhost domain1.com domain2.com
Now you can browse to http://domain1.com and http://domain2.com , and the pages will be
served from your local web server.
Step 3: Create the example pages
First, you'll need two pages in your working directory. Call them example-1.html and ex-
ample-2.html, and add the markup shown in the following listing to the body section. This
markup is even simpler than the cross-document messaging example in chapter 4 because
JavaScript will add the iframe.
Listing F.1. Channel messaging/example-1.html body content
<ul id = "log" ></ul>
<form id = "msgform" >
<input type = "text" id = "msg" >
<input type = "submit" >
</form>
Search WWH ::




Custom Search