Tải bản đầy đủ - 0trang
Browser control: Filling the window with content
content. You could also use it to write to a window that already has content. But it will
overwrite all the HTML of the original document, replacing its content entirely.
Instead of assigning the HTML string to a variable and specifying the variable inside the
parentheses, you could just put the HTML string inside the parentheses, enclosed in
quotes of course. But this would be even more unwieldy than the example code.
The second way to fill the window with content is to assign a document to it, as you
learned to do in previous chapters.
monkeyWindow.location.href = "http://www.animals.com/capuchin.html";
The third and most common way to fill the window with content is to include the
document assignment in the statement that opens the window.
var monkeyWindow = window.open("http://www.animals.com/capuchin.html");
If the document you're opening in the popup shares the same host and directory as the
original document, you can just write...
var monkeyWindow = window.open("capuchin.html");
This is how you close a window.
Find the interactive coding exercises for this chapter at:
Controlling the window's size and location
In the last chapter you learned to open a new window without parameters—a full-size
You also learned to open a window with a single parameter—a URL.
A second parameter that you can include is a window name.
var monkeyWindow = window.open("monk.html", "win1");
In the statement above, the second item in the parentheses, "win1", is the name.
The name is useful for specifying the target attribute of an or