Assignment

We've learned how to change the contents of the status bar of a window we've opened using JavaScript:

var my_window = window.open("http://www.nostarch.com","my_window");
my_window.status = "I'm in the new window's status bar!";

We can use a similar technique to swap an image in a window we've opened using JavaScript. Remember, the code to swap an image looks like this, where the_image is the name of an image on the page:

window.document.the_image.src = "new_image.gif"

To swap an image in another window, just replace window in the script with the name of the window containing the image.

Your homework assignment is to write a page (let's call it the main page) that contains two links. Write some JavaScript so that when the main page opens, ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.